{"instructions": ["Question 1. What is the main goal of data science?\nA. Analyze and predict future trends\nB. Generate massive amounts of data\nC. Answer questions using data\nD. Increase the use of technology", "Question 2. The rise of data science is largely due to:\nA. Reduction in data generation\nB. Rapid increase in computing capabilities and data generation\nC. Increase in computer programming skills\nD. Rise in demand for statisticians", "Question 3. Which of the following characteristics does not belong to big data?\nA. Volume\nB. Velocity\nC. Variety\nD. Valuation", "Question 4. Which of the following represents 'qualitative' data?\nA. The weight of a person\nB. The gender of a person\nC. The age of a person\nD. The treatment group", "Question 5. Why do we need version control in data science?\nA. It allows you to revisit and compare different versions of your work.\nB. It increases the volume of data.\nC. It speeds up data analysis.\nD. It makes the data look visually appealing.", "Question 6. What does the 'volume' characteristic in Big Data refer to?\nA. The speed at which data is generated\nB. The different types of data\nC. The size of the datasets\nD. The volume of data from website or book", "Question 7. In the Venn diagram illustrating the data science field, which component is NOT included?\nA. Software programming\nB. Substantive expertise\nC. Data visualization\nD. Math and statistics", "Question 8. What do hacking skills in data science primarily pertain to?\nA. Gaining unauthorized access to data\nB. Data cleaning and formatting\nC. Performing illegal data cleaning and collection\nD. hack into others' computer system", "Question 9. Which of these is NOT a typical component of a data science project?\nA. Developing the question\nB. Gathering and preparing the data\nC. Running a focus group\nD. Communicating your findings\n", "Question 10. In the data science process, what typically follows data analysis?\nA. Asking a question\nB. Gathering data\nC. Make a presentation to show your findings\nD. report your findings", "Question 11. Which of the following best describes the concept of modeling in data science?\nA. Creating a physical model of the data\nB. Using statistical or machine-learning techniques to analyze the data\nC. Designing the layout of the data in a database\nD. Modeling the data distribution with deep learning", "Question 12. What can influence the type of questions you can ask in a data science project?\nA. The amount of data you have\nB. The type of data available to you\nC. The software you are using for data analysis\nD. People you want to interview.", "Question 13. Which of the following is NOT a standard step in a data science project?\nA. Gathering data\nB. Analyzing data\nC. Painting data\nD. communicating the results", "Question 14. In Hilary Parker's study of baby names, what unique characteristic did the name \"Hilary\" demonstrate when compared to other names that also dropped in popularity?\nA. The name Hilary rose in popularity suddenly and then dropped off.\nB. The name Hilary remained popular for an extended period and then experienced a significant drop in popularity.\nC. The name Hilary's popularity fluctuated frequently over the years.\nD. Hilary remained popular for a longer period."], "outputs": ["C", "B", "D", "BD", "A", "C", "C", "B", "C", "CD", "B", "ABC", "C", "B"], "input": "What is Data Science?\nHello and welcome to the Data Scientist's Toolbox, the first course in the Data Science Specialization series. Here, we will be going over the basics of data science and introducing you to the tools that will be used throughout the series. So, the first question you probably need answered going into this course is, what is data science? That is a great question. To different people this means different things, but at its core, data science is using data to answer questions. This is a pretty broad definition and that's because it's a pretty broad field. Data science can involve statistics, computer science, mathematics, data cleaning and formatting, and data visualization. An Economist Special Report sums up this melange of skills well. They state that a data scientist is broadly defined as someone who combines the skills of software programmer, statistician, and storyteller/artists to extract the nuggets of gold hidden under mountains of data. By the end of these courses, hopefully you will feel equipped to do just that. One of the reasons for the rise of data science in recent years is the vast amount of data currently available and being generated. Not only are massive amounts of data being collected about many aspects of the world and our lives, but we simultaneously have the rise of inexpensive computing. This has created the perfect storm in which we enrich data and the tools to analyze it, rising computer memory capabilities, better processors, more software and now, more data scientists with the skills to put this to use and answer questions using this data. There is a little anecdote that describes the truly exponential growth of data generation we are experiencing. In the third century BC, the Library of Alexandria was believed to house the sum of human knowledge. Today, there is enough information in the world to give every person alive 320 times as much of it as historians think was stored in Alexandria's entire collection, and that is still growing. We'll talk a little bit more about big data in a later lecture. But it deserves an introduction here since it has been so integral to the rise of data science. There are a few qualities that characterize big data. The first is volume. As the name implies, big data involves large datasets. These large datasets are becoming more and more routine. For example, say you had a question about online video. Well, YouTube has approximately 300 hours of video uploaded every minute. You would definitely have a lot of data available to you to analyze. But you can see how this might be a difficult problem to wrangle all of that data. This brings us to the second quality of Big Data, velocity. Data is being generated and collected faster than ever before. In our YouTube example, new data is coming at you every minute. In a completely different example, say you have a question about shipping times of rats. Well, most transport trucks have real-time GPS data available. You could in real time analyze the trucks movements if you have the tools and skills to do so. The third quality of big data is variety. In the examples I've mentioned so far, you have different types of data available to you. In the YouTube example, you could be analyzing video or audio, which is a very unstructured dataset, or you could have a database of video lengths, views or comments, which is a much more structured data set to analyze. So, we've talked about what data science is and what sorts of data it deals with, but something else we need to discuss is what exactly a data scientist is. The most basic of definitions would be that a data scientist is somebody who uses data to answer questions. But more importantly to you, what skills does a data scientist embody? To answer this, we have this illustrative Venn diagram in which data science is the intersection of three sectors, substantive expertise, hacking skills, and math and statistics. To explain a little on what we mean by this, we know that we use data science to answer questions. So first, we need to have enough expertise in the area that we want to ask about in order to formulate our questions, and to know what sorts of data are appropriate to answer that question. Once we have our question and appropriate data, we know from the sorts of data that data science works with. Oftentimes it needs to undergo significant cleaning and formatting. This often takes computer programming/hacking skills. Finally, once we have our data, we need to analyze it. This often takes math and stats knowledge. In this specialization, we'll spend a bit of time focusing on each of these three sectors. But we'll primarily focus on math and statistics knowledge and hacking skills. For hacking skills, we'll focus on teaching two different components, computer programming or at least computer programming with R which will allow you to access data, play around with it, analyze it, and plot it. Additionally, we'll focus on having you learn how to go out and get answers to your programming questions. One reason data scientists are in such demand is that most of the answers are not already outlined in textbooks. A data scientist needs to be somebody who knows how to find answers to novel problems. Speaking of that demand, there is a huge need for individuals with data science skills. Not only are machine-learning engineers, data scientists, and big data engineers among the top emerging jobs in 2017 according to LinkedIn, the demand far exceeds the supply. They state, \"Data scientists roles have grown over 650 percent since 2012. But currently, 35,000 people in the US have data science skills while hundreds of companies are hiring for those roles - even those you may not expect in sectors like retail and finance. Supply of candidates for these roles cannot keep up with demand.\" This is a great time to be getting into data science. Not only do we have more and more data, and more and more tools for collecting, storing, and analyzing it, but the demand for data scientists is becoming increasingly recognized as important in many diverse sectors, not just business and academia. Additionally, according to Glassdoor, in which they ranked the top 50 best jobs in America, data scientist is THE top job in the US in 2017, based on job satisfaction, salary, and demand. The diversity of sectors in which data science is being used is exemplified by looking at examples of data scientists. One place we might not immediately recognize the demand for data science is in sports. Daryl Morey is the general manager of a US basketball team, the Houston Rockets. Despite not having a strong background in basketball, Morey was awarded the job as GM on the basis of his bachelor's degree in computer science and his MBA from MIT. He was chosen for his ability to collect and analyze data and use that to make informed hiring decisions. Another data scientists that you may have heard of his Hilary Mason. She is a co-founder of FastForward Labs, a machine learning company recently acquired by Cloudera, a data science company, and is the Data Scientist in Residence at Accel. Broadly, she uses data to answer questions about mining the web and understanding the way that humans interact with each other through social media. Finally, Nate Silver is one of the most famous data scientists or statisticians in the world today. He is founder and editor in chief at FiveThirtyEight, a website that uses statistical analysis - hard numbers - to tell compelling stories about elections, politics, sports, science, economics, and lifestyle. He uses large amounts of totally free public data to make predictions about a variety of topics. Most notably, he makes predictions about who will win elections in the United States, and has a remarkable track record for accuracy doing so. One great example of data science in action is from 2009 in which researchers at Google analyzed 50 million commonly searched terms over a five-year period and compared them against CDC data on flu outbreaks. Their goal was to see if certain searches coincided with outbreaks of the flu. One of the benefits of data science and using big data is that it can identify correlations. In this case, they identified 45 words that had a strong correlation with the CDC flu outbreak data. With this data, they have been able to predict flu outbreaks based solely off of common Google searches. Without this mass amounts of data, these 45 words could not have been predicted beforehand. Now that you have had this introduction into data science, all that really remains to cover here is a summary of what it is that we will be teaching you throughout this course. To start, we'll go over the basics of R. R is the main programming language that we will be working with in this course track. So, a solid understanding of what it is, how it works, and getting it installed on your computer is a must. We'll then transition into RStudio, which is a very nice graphical interface to R, that should make your life easier. We'll then talk about version control, why it is important, and how to integrate it into your work. Once you have all of these basics down, you'll be all set to apply these tools to answering your very own data science questions. Looking forward to learning with you. Let's get to it.\n\nWhat is Data?\nSince we've spent some time discussing what data science is, we should spend some time looking at what exactly data is. First, let's look at what a few trusted sources consider data to be. First up, we'll look at the Cambridge English Dictionary which states that data is information, especially facts or numbers collected to be examined and considered and used to help decision-making. Second, we'll look at the definition provided by Wikipedia which is, a set of values of qualitative or quantitative variables. These are slightly different definitions and they get a different components of what data is. Both agree that data is values or numbers or facts. But the Cambridge definition focuses on the actions that surround data. Data is collected, examined and most importantly, used to inform decisions. We've focused on this aspect before. We've talked about how the most important part of data science is the question and how all we are doing is using data to answer the question. The Cambridge definition focuses on this. The Wikipedia definition focuses more on what data entails. And although it is a fairly short definition, we'll take a second to parse this and focus on each component individually. So, the first thing to focus on is, a set of values. To have data, you need a set of items to measure from. In statistics, this set of items is often called the population. The set as a whole is what you are trying to discover something about. The next thing to focus on is, variables. Variables are measurements or characteristics of an item. Finally, we have both qualitative and quantitative variables. Qualitative variables are, unsurprisingly, information about qualities. They are things like country of origin, sex or treatment group. They're usually described by words, not numbers and they are not necessarily ordered. Quantitative variables on the other hand, are information about quantities. Quantitative measurements are usually described by numbers and are measured on a continuous ordered scale. They're things like height, weight and blood pressure. So, taking this whole definition into consideration we have measurements, either qualitative or quantitative on a set of items making up data. Not a bad definition. When we were going over the definitions, our examples of data, country of origin, sex, height, weight are pretty basic examples. You can easily envision them in a nice-looking spreadsheet like this one, with individuals along one side of the table in rows, and the measurements for those variables along the columns. Unfortunately, this is rarely how data is presented to you. The data sets we commonly encounter are much messier. It is our job to extract the information we want, corralled into something tidy like the table here, analyze it appropriately and often, visualize our results. These are just some of the data sources you might encounter. And we'll briefly look at what a few of these data sets often look like, or how they can be interpreted. But one thing they have in common is the messiness of the data. You have to work to extract the information you need to answer your question. One type of data that I work with regularly, is sequencing data. This data is generally first encountered in the fast queue format. The raw file format produced by sequencing machines. These files are often hundreds of millions of lines long, and it is our job to parse this into an understandable and interpretable format, and infer something about that individual's genome. In this case, this data was interpreted into expression data, and produced a plot called the Volcano Plot. One rich source of information is countrywide censuses. In these, almost all members of a country answer a set of standardized questions and submit these answers to the government. When you have that many respondents, the data is large and messy. But once this large database is ready to be queried, the answers embedded are important. Here we have a very basic result of the last US Census. In which all respondents are divided by sex and age. This distribution is plotted in this population pyramid plot. I urge you to check out your home country census bureau, if available and look at some of the data there. This is a mock example of an electronic medical record. This is a popular way to store health information, and more and more population-based studies are using this data to answer questions and make inferences about populations at large, or as a method to identify ways to improve medical care. For example, if you are asking about a population's common allergies, you will have to extract many individuals allergy information, and put that into an easily interpretable table format where you will then perform your analysis. A more complex data source to analyze our images slash videos. There is a wealth of information coded in an image or video, and it is just waiting to be extracted. An example of image analysis that you may be familiar with is when you upload a picture to Facebook. Not only does it automatically recognize faces in the picture, but then suggests who they maybe. A fun example you can play with is The Deep Dream software that was originally designed to detect faces in an image, but has since moved onto more artistic pursuits. There is another fun Google initiative involving image analysis, where you help provide data to Google's machine learning algorithm by doodling. Recognizing that we've spent a lot of time going over what data is, we need to reiterate data is important, but it is secondary to your question. A good data scientist asks questions first and seeks out relevant data second. Admittedly, often the data available will limit, or perhaps even enable certain questions you are trying to ask. In these cases, you may have to re-frame your question or answer a related question but the data itself does not drive the question asking. In this lesson we focused on data, both in defining it and in exploring what data may look like and how it can be used. First, we looked at two definitions of data. One that focuses on the actions surrounding data, and another on what comprises data. The second definition embeds the concepts of populations, variables and looks at the differences between quantitative and qualitative data. Second, we examined different sources of data that you may encounter and emphasized the lack of tidy data sets. Examples of messy data sets where raw data needs to be rankled into an interpretable form, can include sequencing data, census data, electronic medical records et cetera. Finally, we return to our beliefs on the relationship between data and your question and emphasize the importance of question first strategies. You could have all the data you could ever hope for, but if you don't have a question to start, the data is useless.\n\nThe Data Science Process\nIn the first few lessons of this course, we discuss what data and data science are and ways to get help. What we haven't yet covered is what an actual data science project looks like. To do so, we'll first step through an actual data science project, breaking down the parts of a typical project and then provide a number of links to other interesting data science projects. Our goal in this lesson is to expose you to the process one goes through as they carry out data science projects. Every data science project starts with a question that is to be answered with data. That means that forming the question is an important first step in the process. The second step, is finding or generating the data you're going to use to answer that question. With the question solidified and data in hand, the data are then analyzed first by exploring the data and then often by modeling the data, which means using some statistical or machine-learning techniques to analyze the data and answer your question. After drawing conclusions from this analysis, the project has to be communicated to others. Sometimes this is the report you send to your boss or team at work, other times it's a blog post. Often it's a presentation to a group of colleagues. Regardless, a data science project almost always involve some form of communication of the project's findings. We'll walk through these steps using a data science project example below. For this example, we're going to use an example analysis from a data scientist named Hilary Parker. Her work can be found on her blog and the specific project we'll be working through here is from 2013 entitled, Hilary: The most poison baby name in US history. To get the most out of this lesson, click on that link and read through Hilary's post. Once you're done, come on back to this lesson and read through the breakdown of this post. When setting out on a data science project, it's always great to have your question well-defined. Additional questions may pop up as you do the analysis. But knowing what you want to answer with your analysis is a really important first step. Hilary Parker's question is included in bold in her post. Highlighting this makes it clear that she's interested and answer the following question; is Hilary/Hillary really the most rapidly poison naming recorded American history? To answer this question, Hilary collected data from the Social Security website. This data set included 1,000 most popular baby names from 1880 until 2011. As explained in the blog post, Hilary was interested in calculating the relative risk for each of the 4,110 different names in her data set from one year to the next, from 1880-2011. By hand, this would be a nightmare. Thankfully, by writing code in R, all of which is available on GitHub, Hilary was able to generate these values for all these names across all these years. It's not important at this point in time to fully understand what a relative risk calculation is. Although, Hilary does a great job breaking it down in her post. But it is important to know that after getting the data together, the next step is figuring out what you need to do with that data in order to answer your question. For Hilary's question, calculating the relative risk for each name from one year to the next from 1880-2011, and looking at the percentage of babies named each name in a particular year would be what she needed to do to answer her question. What you don't see in the blog post is all of the code Hilary wrote to get the data from the Social Security website, to get it in the format she needed to do the analysis and to generate the figures. As mentioned above, she made all this code available on GitHub so that others could see what she did and repeat her steps if they wanted. In addition to this code, data science projects often involve writing a lot of code and generating a lot of figures that aren't included in your final results. This is part of the data science process to figuring out how to do what you want to do to answer your question of interest. It's part of the process. It doesn't always show up in your final project and can be very time consuming. That said, given that Hilary now had the necessary values calculated, she began to analyze the data. The first thing she did was look at the names with the biggest drop in percentage from one year to the next. By this preliminary analysis, Hilary was sixth on the list. Meaning there were five other names that had had a single year drop in popularity larger than the one the name Hilary experienced from 1992-1993. In looking at the results of this analysis, the first five years appeared peculiar to Hilary Parker. It's always good to consider whether or not the results were what you were expecting from many analysis. None of them seemed to be names that were popular for long periods of time. To see if this hunch was true, Hilary plotted the percent of babies born each year with each of the names from this table. What she found was that among these poisoned names, names that experienced a big drop from one year to the next in popularity, all of the names other than Hilary became popular all of a sudden and then dropped off in popularity. Hilary Parker was able to figure out why most of these other names became popular. So definitely read that section of her post. The name, Hilary, however, was different. It was popular for a while and then completely dropped off in popularity. To figure out what was specifically going on with the name Hilary, she removed names that became popular for short periods of time before dropping off and only looked at names that were in the top 1,000 for more than 20 years. The results from this analysis definitively showed that Hilary had the quickest fall from popularity in 1992 of any female baby named between 1880 and 2011. Marian's decline was gradual over many years. For the final step in this data analysis process, once Hilary Parker had answered her question, it was time to share it with the world. An important part of any data science project is effectively communicating the results of the project. Hilary did so by writing a wonderful blog post that communicated the results of her analysis. Answered the question she set out to answer, and did so in an entertaining way. Additionally, it's important to note that most projects build off someone else's work. It's really important to give those people credit. Hilary accomplishes this by linking to a blog post where someone had asked a similar question previously, to the Social Security website where she got the data and where she learned about web scraping. Hilary's work was carried out using the R programming language. Throughout the courses in this series, you'll learn the basics of programming in R, exploring and analyzing data, and how to build reports and web applications that allow you to effectively communicate your results. To give you an example of the types of things that can be built using the R programming and suite of available tools that use R, below are a few examples of the types of things that have been built using the data science process and the R programming language. The types of things that you'll be able to generate by the end of this series of courses. Masters students at the University of Pennsylvania set out to predict the risk of opioid overdoses in Providence, Rhode Island. They include details on the data they used. The steps they took to clean their data, their visualization process, and their final results. While the details aren't important now, seeing the process and what types of reports can be generated is important. Additionally, they've created a Shiny app, which is an interactive web application. This means that you can choose what neighborhood in Providence you want to focus on. All of this was built using R programming. The following are smaller projects than the example above, but data science projects nonetheless. In each project, the author had a question they wanted to answer and use data to answer that question. They explored, visualized, and analyzed the data. Then, they wrote blog posts to communicate their findings. Take a look to learn more about the topics listed and to see how others work through the data science project process and communicate their results. Maelle Samuel looked to use data to see where one should live in the US given their weather preferences. David Robinson carried out an analysis of Trump's tweets to show that Trump only writes the angrier ones himself. Charlotte Galvin used open data available from the City of Toronto to build a map with information about sexual health clinics. In this lesson, we hope we've conveyed that sometimes data science projects are tackling difficult questions. Can we predict the risk of opioid overdose? While other times the goal of the project is to answer a question you're interested in personally; is Hilary the most rapidly poisoned baby name in recorded American history? In either case, the process is similar. You have to form your question, get data, explore and analyze your data, and communicate your results. With the tools you will learn in this series of courses, you will be able to set out and carry out your own data science projects like the examples included in this lesson.\n", "source": "coursera_a", "evaluation": "exam"}
{"instructions": ["Question 1. Which of the following statements about Adam is False?\nA. We usually use \u201cdefault\u201d values for the hyperparameters \u03b21,\u03b22 and \u03b5 in Adam ( \u03b21 = 0.9 \u03b22 = 0.999, \u03b5=10\u22128)\nB. Adam should be used with batch gradient computations, not with mini-batches.\nC. The learning rate hyperparameter \u03b1 in Adam usually needs to be tuned.\nD. Adam combines the advantages of RMSProp and momentum", "Question 2. Suppose you have a deep learning model with 5 million parameters. Which of these techniques could help to reduce the memory requirements during training?\nA. Using mini-batch gradient descent instead of batch gradient descent\nB. Implementing dropout regularization\nC. Applying weight sharing\nD. Reducing the number of hidden layers", "Question 3. Which of the following statements is true about the initialization of weights in a deep neural network?\nA. Initializing all weights to zero is a good practice because it speeds up the convergence of the model.\nB. Initializing all weights to the same non-zero value is a good practice because it ensures symmetry in the model.\nC. Initializing weights to small random values is a good practice because it breaks the symmetry in the model.\nD. Initializing weights to large random values is a good practice because it speeds up the convergence of the model.", "Question 4. What is the main advantage of using a ReLU (rectified linear unit) activation function over a sigmoid activation function in deep neural networks?\nA. ReLU is computationally more efficient and helps to mitigate the vanishing gradient problem.\nB. ReLU provides a more complex decision boundary, leading to better performance.\nC. ReLU ensures that all neurons in the network are activated, increasing the model capacity.\nD. ReLU allows for better interpretability of the model's learned features.", "Question 5. In the context of deep learning, what is the purpose of using batch normalization?\nA. To improve the generalization performance and stabilize the training process.\nB. To speed up the training process by reducing the internal covariate shift.\nC. To simplify the architecture of the neural network.\nD. To increase the interpretability of the learned features.", "Question 6. What is the main advantage of using a dropout regularization technique in deep neural networks?\nA. It reduces the risk of overfitting by preventing complex co-adaptations between neurons.\nB. It speeds up the training process and provides more accurate results.\nC. It reduces the parameters of the neural network.\nD. It randomly set some values in a neural network to zero.", "Question 7. Which of the following assertions regarding mini-batch gradient descent do you concur with?\nA. Undertaking one epoch (a full pass through the training dataset) with mini-batch gradient descent is quicker than conducting one epoch with batch gradient descent.\nB. A single cycle of mini-batch gradient descent (performing calculations on one mini-batch) is faster than one cycle of batch gradient descent.\nC. You should set up mini-batch gradient descent without a direct for-loop over various mini-batches, thereby ensuring the algorithm handles all mini-batches simultaneously (vectorization).\nD. Mini-batch gradient descent always converges to the global minimum of the cost function, while batch gradient descent may get stuck in a local minimum.", "Question 8. Why is it important to shuffle the training data when using mini-batch gradient descent?\nA. Shuffling ensures that the model sees a diverse set of examples in each mini-batch, which can help the model generalize better.\nB. Shuffling speeds up the training process by reducing the risk of getting stuck in local optima.\nC. Shuffling reduces the risk of overfitting by preventing the model from memorizing the order of the training data.\nD. Shuffling improves the interpretability of the learned features.", "Question 9. Which of the following techniques can help to mitigate the vanishing gradient problem in deep neural networks?\nA. Using ReLU activation functions instead of sigmoid activation functions.\nB. Initializing weights to small random values.\nC. Implementing batch normalization.\nD. Applying dropout regularization.", "Question 10. In the context of deep learning, what is the purpose of using a learning rate decay schedule?\nA. To speed up the training process by allowing the model to take larger steps in the early stages of training.\nB. To improve the performance by forcing the model to pay attention to small features.\nC. To help the model converge more accurately by taking smaller steps in the later stages of training.\nD. To increase the scale of parameters in neural networks.", "Question 11. Which of the following factors can contribute to the vanishing gradient problem in deep neural networks?\nA. The choice of activation function.\nB. The depth of the network.\nC. The initialization of weights.\nD. The learning rate.", "Question 12. Assume that in a deep learning network, batch gradient descent is unusually slow in identifying a set of parameters that minimize the cost function J(W[1],b[1],\u2026,W[L],b[L]). Which strategies listed below could potentially help in achieving lower values for the cost function more quickly? (Select all relevant options)\nA. Implement mini-batch gradient descent\nB. Adjust the learning rate \u03b1\nC. Implement Adam optimization\nD. Improve the random weight initialization method"], "outputs": ["B", "AC", "C", "A", "B", "A", "B", "A", "AC", "A", "ABC", "ABCD"], "input": "Mini-batch Gradient Descent\nHello, and welcome back. In this week, you learn about optimization algorithms that will enable you to train your neural network much faster. You've heard me say before that applying machine learning is a highly empirical process, is a highly iterative process. In which you just had to train a lot of models to find one that works really well. So, it really helps to really train models quickly. One thing that makes it more difficult is that Deep Learning tends to work best in the regime of big data. We are able to train neural networks on a huge data set and training on a large data set is just slow. So, what you find is that having fast optimization algorithms, having good optimization algorithms can really speed up the efficiency of you and your team. So, let's get started by talking about mini-batch gradient descent. You've learned previously that vectorization allows you to efficiently compute on all m examples, that allows you to process your whole training set without an explicit For loop. That's why we would take our training examples and stack them into these huge matrix capsule Xs. X1, X2, X3, and then eventually it goes up to XM training samples. And similarly for Y this is Y1 and Y2, Y3 and so on up to YM. So, the dimension of X was an X by M and this was 1 by M. Vectorization allows you to process all M examples relatively quickly if M is very large then it can still be slow. For example what if M was 5 million or 50 million or even bigger. With the implementation of gradient descent on your whole training set, what you have to do is, you have to process your entire training set before you take one little step of gradient descent. And then you have to process your entire training sets of five million training samples again before you take another little step of gradient descent. So, it turns out that you can get a faster algorithm if you let gradient descent start to make some progress even before you finish processing your entire, your giant training sets of 5 million examples. In particular, here's what you can do. Let's say that you split up your training set into smaller, little baby training sets and these baby training sets are called mini-batches. And let's say each of your baby training sets have just 1,000 examples each. So, you take X1 through X1,000 and you call that your first little baby training set, also call the mini-batch. And then you take home the next 1,000 examples. X1,001 through X2,000 and the next X1,000 examples and come next one and so on. I'm going to introduce a new notation. I'm going to call this X superscript with curly braces, 1 and I am going to call this, X superscript with curly braces, 2. Now, if you have 5 million training samples total and each of these little mini batches has a thousand examples, that means you have 5,000 of these because you know, 5,000 times 1,000 equals 5 million. Altogether you would have 5,000 of these mini batches. So it ends with X superscript curly braces 5,000 and then similarly you do the same thing for Y. You would also split up your training data for Y accordingly. So, call that Y1 then this is Y1,001 through Y2,000. This is called, Y2 and so on until you have Y5,000. Now, mini batch number T is going to be comprised of XT, and YT. And that is a thousand training samples with the corresponding input output pairs. Before moving on, just to make sure my notation is clear, we have previously used superscript round brackets I to index in the training set so X I, is the I-th training sample. We use superscript, square brackets L to index into the different layers of the neural network. So, ZL comes from the Z value, for the L layer of the neural network and here we are introducing the curly brackets T to index into different mini batches. So, you have XT, YT. And to check your understanding of these, what is the dimension of XT and YT? Well, X is an X by M. So, if X1 is a thousand training examples or the X values for a thousand examples, then this dimension should be Nx by 1,000 and X2 should also be Nx by 1,000 and so on. So, all of these should have dimension MX by 1,000 and these should have dimension 1 by 1,000. To explain the name of this algorithm, batch gradient descent, refers to the gradient descent algorithm we have been talking about previously. Where you process your entire training set all at the same time. And the name comes from viewing that as processing your entire batch of training samples all at the same time. I know it's not a great name but that's just what it's called. Mini-batch gradient descent in contrast, refers to algorithm which we'll talk about on the next slide and which you process is single mini batch XT, YT at the same time rather than processing your entire training set XY the same time. So, let's see how mini-batch gradient descent works. To run mini-batch gradient descent on your training sets you run for T equals 1 to 5,000 because we had 5,000 mini batches as high as 1,000 each. What are you going to do inside the For loop is basically implement one step of gradient descent using XT comma YT. It is as if you had a training set of size 1,000 examples and it was as if you were to implement the algorithm you are already familiar with, but just on this little training set size of M equals 1,000. Rather than having an explicit For loop over all 1,000 examples, you would use vectorization to process all 1,000 examples sort of all at the same time. Let us write this out. First, you implement forward prop on the inputs. So just on XT. And you do that by implementing Z1 equals W1. Previously, we would just have X there, right? But now you are processing the entire training set, you are just processing the first mini-batch so that it becomes XT when you're processing mini-batch T. Then you will have A1 equals G1 of Z1, a capital Z since this is actually a vectorized implementation and so on until you end up with AL, as I guess GL of ZL, and then this is your prediction. And you notice that here you should use a vectorized implementation. It's just that this vectorized implementation processes 1,000 examples at a time rather than 5 million examples. Next you compute the cost function J which I'm going to write as one over 1,000 since here 1,000 is the size of your little training set. Sum from I equals one through L of really the loss of Y^I YI. And this notation, for clarity, refers to examples from the mini batch XT YT. And if you're using regularization, you can also have this regularization term. Move it to the denominator times sum of L, Frobenius norm of the weight matrix squared. Because this is really the cost on just one mini-batch, I'm going to index as cost J with a superscript T in curly braces. You notice that everything we are doing is exactly the same as when we were previously implementing gradient descent except that instead of doing it on XY, you're not doing it on XT YT. Next, you implement back prop to compute gradients with respect to JT, you are still using only XT YT and then you update the weights W, really WL, gets updated as WL minus alpha D WL and similarly for B. This is one pass through your training set using mini-batch gradient descent. The code I have written down here is also called doing one epoch of training and epoch is a word that means a single pass through the training set. Whereas with batch gradient descent, a single pass through the training set allows you to take only one gradient descent step. With mini-batch gradient descent, a single pass through the training set, that is one epoch, allows you to take 5,000 gradient descent steps. Now of course you want to take multiple passes through the training set which you usually want to, you might want another for loop for another while loop out there. So you keep taking passes through the training set until hopefully you converge or at least approximately converged. When you have a large training set, mini-batch gradient descent runs much faster than batch gradient descent and that's pretty much what everyone in Deep Learning will use when you're training on a large data set. In the next video, let's delve deeper into mini-batch gradient descent so you can get a better understanding of what it is doing and why it works so well.\n\nUnderstanding Mini-batch Gradient Descent\nIn the previous video, you saw how you can use mini-batch gradient descent to start making progress and start taking gradient descent steps, even when you're just partway through processing your training set even for the first time. In this video, you learn more details of how to implement gradient descent and gain a better understanding of what it's doing and why it works. With batch gradient descent on every iteration you go through the entire training set and you'd expect the cost to go down on every single iteration.\nSo if we've had the cost function j as a function of different iterations it should decrease on every single iteration. And if it ever goes up even on iteration then something is wrong. Maybe you're running ways to big. On mini batch gradient descent though, if you plot progress on your cost function, then it may not decrease on every iteration. In particular, on every iteration you're processing some X{t}, Y{t} and so if you plot the cost function J{t}, which is computer using just X{t}, Y{t}. Then it's as if on every iteration you're training on a different training set or really training on a different mini batch. So you plot the cross function J, you're more likely to see something that looks like this. It should trend downwards, but it's also going to be a little bit noisier.\nSo if you plot J{t}, as you're training mini batch in descent it may be over multiple epochs, you might expect to see a curve like this. So it's okay if it doesn't go down on every derivation. But it should trend downwards, and the reason it'll be a little bit noisy is that, maybe X{1}, Y{1} is just the rows of easy mini batch so your cost might be a bit lower, but then maybe just by chance, X{2}, Y{2} is just a harder mini batch. Maybe you needed some mislabeled examples in it, in which case the cost will be a bit higher and so on. So that's why you get these oscillations as you plot the cost when you're running mini batch gradient descent. Now one of the parameters you need to choose is the size of your mini batch. So m was the training set size on one extreme, if the mini-batch size,\n= m, then you just end up with batch gradient descent.\nAlright, so in this extreme you would just have one mini-batch X{1}, Y{1}, and this mini-batch is equal to your entire training set. So setting a mini-batch size m just gives you batch gradient descent. The other extreme would be if your mini-batch size, Were = 1.\nThis gives you an algorithm called stochastic gradient descent.\nAnd here every example is its own mini-batch.\nSo what you do in this case is you look at the first mini-batch, so X{1}, Y{1}, but when your mini-batch size is one, this just has your first training example, and you take derivative to sense that your first training example. And then you next take a look at your second mini-batch, which is just your second training example, and take your gradient descent step with that, and then you do it with the third training example and so on looking at just one single training sample at the time.\nSo let's look at what these two extremes will do on optimizing this cost function. If these are the contours of the cost function you're trying to minimize so your minimum is there. Then batch gradient descent might start somewhere and be able to take relatively low noise, relatively large steps. And you could just keep matching to the minimum. In contrast with stochastic gradient descent If you start somewhere let's pick a different starting point. Then on every iteration you're taking gradient descent with just a single strain example so most of the time you hit two at the global minimum. But sometimes you hit in the wrong direction if that one example happens to point you in a bad direction. So stochastic gradient descent can be extremely noisy. And on average, it'll take you in a good direction, but sometimes it'll head in the wrong direction as well. As stochastic gradient descent won't ever converge, it'll always just kind of oscillate and wander around the region of the minimum. But it won't ever just head to the minimum and stay there. In practice, the mini-batch size you use will be somewhere in between.\nSomewhere between in 1 and m and 1 and m are respectively too small and too large. And here's why. If you use batch gradient descent, So this is your mini batch size equals m.\nThen you're processing a huge training set on every iteration. So the main disadvantage of this is that it takes too much time too long per iteration assuming you have a very long training set. If you have a small training set then batch gradient descent is fine. If you go to the opposite, if you use stochastic gradient descent,\nThen it's nice that you get to make progress after processing just tone example that's actually not a problem. And the noisiness can be ameliorated or can be reduced by just using a smaller learning rate. But a huge disadvantage to stochastic gradient descent is that you lose almost all your speed up from vectorization.\nBecause, here you're processing a single training example at a time. The way you process each example is going to be very inefficient. So what works best in practice is something in between where you have some,\nMini-batch size not to big or too small.\nAnd this gives you in practice the fastest learning.\nAnd you notice that this has two good things going for it. One is that you do get a lot of vectorization. So in the example we used on the previous video, if your mini batch size was 1000 examples then, you might be able to vectorize across 1000 examples which is going to be much faster than processing the examples one at a time.\nAnd second, you can also make progress,\nWithout needing to wait til you process the entire training set.\nSo again using the numbers we have from the previous video, each epoch each part your training set allows you to see 5,000 gradient descent steps.\nSo in practice they'll be some in-between mini-batch size that works best. And so with mini-batch gradient descent we'll start here, maybe one iteration does this, two iterations, three, four. And It's not guaranteed to always head toward the minimum but it tends to head more consistently in direction of the minimum than the consequent descent. And then it doesn't always exactly convert or oscillate in a very small region. If that's an issue you can always reduce the learning rate slowly. We'll talk more about learning rate decay or how to reduce the learning rate in a later video. So if the mini-batch size should not be m and should not be 1 but should be something in between, how do you go about choosing it? Well, here are some guidelines. First, if you have a small training set, Just use batch gradient descent.\nIf you have a small training set then no point using mini-batch gradient descent you can process a whole training set quite fast. So you might as well use batch gradient descent. What a small training set means, I would say if it's less than maybe 2000 it'd be perfectly fine to just use batch gradient descent. Otherwise, if you have a bigger training set, typical mini batch sizes would be,\nAnything from 64 up to maybe 512 are quite typical. And because of the way computer memory is layed out and accessed, sometimes your code runs faster if your mini-batch size is a power of 2. All right, so 64 is 2 to the 6th, is 2 to the 7th, 2 to the 8, 2 to the 9, so often I'll implement my mini-batch size to be a power of 2. I know that in a previous video I used a mini-batch size of 1000, if you really wanted to do that I would recommend you just use your 1024, which is 2 to the power of 10. And you do see mini batch sizes of size 1024, it is a bit more rare. This range of mini batch sizes, a little bit more common. One last tip is to make sure that your mini batch,\nAll of your X{t}, Y{t} that that fits in CPU/GPU memory.\nAnd this really depends on your application and how large a single training sample is. But if you ever process a mini-batch that doesn't actually fit in CPU, GPU memory, whether you're using the process, the data. Then you find that the performance suddenly falls of a cliff and is suddenly much worse. So I hope this gives you a sense of the typical range of mini batch sizes that people use. In practice of course the mini batch size is another hyper parameter that you might do a quick search over to try to figure out which one is most sufficient of reducing the cost function j. So what i would do is just try several different values. Try a few different powers of two and then see if you can pick one that makes your gradient descent optimization algorithm as efficient as possible. But hopefully this gives you a set of guidelines for how to get started with that hyper parameter search. You now know how to implement mini-batch gradient descent and make your algorithm run much faster, especially when you're training on a large training set. But it turns out there're even more efficient algorithms than gradient descent or mini-batch gradient descent. Let's start talking about them in the next few videos.\n\nExponentially Weighted Averages\nI want to show you a few optimization algorithms. They are faster than gradient descent. In order to understand those algorithms, you need to be able they use something called exponentially weighted averages. Also called exponentially weighted moving averages in statistics. Let's first talk about that, and then we'll use this to build up to more sophisticated optimization algorithms. So, even though I now live in the United States, I was born in London. So, for this example I got the daily temperature from London from last year. So, on January 1, temperature was 40 degrees Fahrenheit. Now, I know most of the world uses a Celsius system, but I guess I live in United States which uses Fahrenheit. So that's four degrees Celsius. And on January 2, it was nine degrees Celsius and so on. And then about halfway through the year, a year has 365 days so, that would be, sometime day number 180 will be sometime in late May, I guess. It was 60 degrees Fahrenheit which is 15 degrees Celsius, and so on. So, it start to get warmer, towards summer and it was colder in January. So, you plot the data you end up with this. Where day one being sometime in January, that you know, being the, beginning of summer, and that's the end of the year, kind of late December. So, this would be January, January 1, is the middle of the year approaching summer, and this would be the data from the end of the year. So, this data looks a little bit noisy and if you want to compute the trends, the local average or a moving average of the temperature, here's what you can do. Let's initialize V zero equals zero. And then, on every day, we're going to average it with a weight of 0.9 times whatever appears as value, plus 0.1 times that day temperature. So, theta one here would be the temperature from the first day. And on the second day, we're again going to take a weighted average. 0.9 times the previous value plus 0.1 times today's temperature and so on. Day two plus 0.1 times theta three and so on. And the more general formula is V on a given day is 0.9 times V from the previous day, plus 0.1 times the temperature of that day. So, if you compute this and plot it in red, this is what you get. You get a moving average of what's called an exponentially weighted average of the daily temperature. So, let's look at the equation we had from the previous slide, it was VT equals, previously we had 0.9. We'll now turn that to prime to beta, beta times VT minus one plus and it previously, was 0.1, I'm going to turn that into one minus beta times theta T, so, previously you had beta equals 0.9. It turns out that for reasons we are going to later, when you compute this you can think of VT as approximately averaging over, something like one over one minus beta, day's temperature. So, for example when beta goes 0.9 you could think of this as averaging over the last 10 days temperature. And that was the red line. Now, let's try something else. Let's set beta to be very close to one, let's say it's 0.98. Then, if you look at 1/1 minus 0.98, this is equal to 50. So, this is, you know, think of this as averaging over roughly, the last 50 days temperature. And if you plot that you get this green line. So, notice a couple of things with this very high value of beta. The plot you get is much smoother because you're now averaging over more days of temperature. So, the curve is just, you know, less wavy is now smoother, but on the flip side the curve has now shifted further to the right because you're now averaging over a much larger window of temperatures. And by averaging over a larger window, this formula, this exponentially weighted average formula. It adapts more slowly, when the temperature changes. So, there's just a bit more latency. And the reason for that is when Beta 0.98 then it's giving a lot of weight to the previous value and a much smaller weight just 0.02, to whatever you're seeing right now. So, when the temperature changes, when temperature goes up or down, there's exponentially weighted average. Just adapts more slowly when beta is so large. Now, let's try another value. If you set beta to another extreme, let's say it is 0.5, then this by the formula we have on the right. This is something like averaging over just two days temperature, and you plot that you get this yellow line. And by averaging only over two days temperature, you have a much, as if you're averaging over much shorter window. So, you're much more noisy, much more susceptible to outliers. But this adapts much more quickly to what the temperature changes. So, this formula is highly implemented, exponentially weighted average. Again, it's called an exponentially weighted, moving average in the statistics literature. We're going to call it exponentially weighted average for short and by varying this parameter or later we'll see such a hyper parameter if you're learning algorithm you can get slightly different effects and there will usually be some value in between that works best. That gives you the red curve which you know maybe looks like a beta average of the temperature than either the green or the yellow curve. You now know the basics of how to compute exponentially weighted averages. In the next video, let's get a bit more intuition about what it's doing.\n\nUnderstanding Exponentially Weighted Averages\nIn the last video, we talked about exponentially weighted averages. This will turn out to be a key component of several optimization algorithms that you used to train your neural networks. So, in this video, I want to delve a little bit deeper into intuitions for what this algorithm is really doing. Recall that this is a key equation for implementing exponentially weighted averages. And so, if beta equals 0.9 you got the red line. If it was much closer to one, if it was 0.98, you get the green line. And it it's much smaller, maybe 0.5, you get the yellow line. Let's look a bit more than that to understand how this is computing averages of the daily temperature. So here's that equation again, and let's set beta equals 0.9 and write out a few equations that this corresponds to. So whereas, when you're implementing it you have T going from zero to one, to two to three, increasing values of T. To analyze it, I've written it with decreasing values of T. And this goes on. So let's take this first equation here, and understand what V100 really is. So V100 is going to be, let me reverse these two terms, it's going to be 0.1 times theta 100, plus 0.9 times whatever the value was on the previous day. Now, but what is V99? Well, we'll just plug it in from this equation. So this is just going to be 0.1 times theta 99, and again I've reversed these two terms, plus 0.9 times V98. But then what is V98? Well, you just get that from here. So you can just plug in here, 0.1 times theta 98, plus 0.9 times V97, and so on. And if you multiply all of these terms out, you can show that V100 is 0.1 times theta 100 plus. Now, let's look at coefficient on theta 99, it's going to be 0.1 times 0.9, times theta 99. Now, let's look at the coefficient on theta 98, there's a 0.1 here times 0.9, times 0.9. So if we expand out the Algebra, this become 0.1 times 0.9 squared, times theta 98. And, if you keep expanding this out, you find that this becomes 0.1 times 0.9 cubed, theta 97 plus 0.1, times 0.9 to the fourth, times theta 96, plus dot dot dot. So this is really a way to sum and that's a weighted average of theta 100, which is the current days temperature and we're looking for a perspective of V100 which you calculate on the 100th day of the year. But those are sum of your theta 100, theta 99, theta 98, theta 97, theta 96, and so on. So one way to draw this in pictures would be if, let's say we have some number of days of temperature. So this is theta and this is T. So theta 100 will be sum value, then theta 99 will be sum value, theta 98, so these are, so this is T equals 100, 99, 98, and so on, ratio of sum number of days of temperature. And what we have is then an exponentially decaying function. So starting from 0.1 to 0.9, times 0.1 to 0.9 squared, times 0.1, to and so on. So you have this exponentially decaying function. And the way you compute V100, is you take the element wise product between these two functions and sum it up. So you take this value, theta 100 times 0.1, times this value of theta 99 times 0.1 times 0.9, that's the second term and so on. So it's really taking the daily temperature, multiply with this exponentially decaying function, and then summing it up. And this becomes your V100. It turns out that, up to details that are for later. But all of these coefficients, add up to one or add up to very close to one, up to a detail called bias correction which we'll talk about in the next video. But because of that, this really is an exponentially weighted average. And finally, you might wonder, how many days temperature is this averaging over. Well, it turns out that 0.9 to the power of 10, is about 0.35 and this turns out to be about one over E, one of the base of natural algorithms. And, more generally, if you have one minus epsilon, so in this example, epsilon would be 0.1, so if this was 0.9, then one minus epsilon to the one over epsilon. This is about one over E, this about 0.34, 0.35. And so, in other words, it takes about 10 days for the height of this to decay to around 1/3 already one over E of the peak. So it's because of this, that when beta equals 0.9, we say that, this is as if you're computing an exponentially weighted average that focuses on just the last 10 days temperature. Because it's after 10 days that the weight decays to less than about a third of the weight of the current day. Whereas, in contrast, if beta was equal to 0.98, then, well, what do you need 0.98 to the power of in order for this to really small? Turns out that 0.98 to the power of 50 will be approximately equal to one over E. So the way to be pretty big will be bigger than one over E for the first 50 days, and then they'll decay quite rapidly over that. So intuitively, this is the hard and fast thing, you can think of this as averaging over about 50 days temperature. Because, in this example, to use the notation here on the left, it's as if epsilon is equal to 0.02, so one over epsilon is 50. And this, by the way, is how we got the formula, that we're averaging over one over one minus beta or so days. Right here, epsilon replace a row of 1 minus beta. It tells you, up to some constant roughly how many days temperature you should think of this as averaging over. But this is just a rule of thumb for how to think about it, and it isn't a formal mathematical statement. Finally, let's talk about how you actually implement this. Recall that we start over V0 initialized as zero, then compute V one on the first day, V2, and so on. Now, to explain the algorithm, it was useful to write down V0, V1, V2, and so on as distinct variables. But if you're implementing this in practice, this is what you do: you initialize V to be called to zero, and then on day one, you would set V equals beta, times V, plus one minus beta, times theta one. And then on the next day, you add update V, to be called to beta V, plus 1 minus beta, theta 2, and so on. And some of it uses notation V subscript theta to denote that V is computing this exponentially weighted average of the parameter theta. So just to say this again but for a new format, you set V theta equals zero, and then, repeatedly, have one each day, you would get next theta T, and then set to V, theta gets updated as beta, times the old value of V theta, plus one minus beta, times the current value of V theta. So one of the advantages of this exponentially weighted average formula, is that it takes very little memory. You just need to keep just one row number in computer memory, and you keep on overwriting it with this formula based on the latest values that you got. And it's really this reason, the efficiency, it just takes up one line of code basically and just storage and memory for a single row number to compute this exponentially weighted average. It's really not the best way, not the most accurate way to compute an average. If you were to compute a moving window, where you explicitly sum over the last 10 days, the last 50 days temperature and just divide by 10 or divide by 50, that usually gives you a better estimate. But the disadvantage of that, of explicitly keeping all the temperatures around and sum of the last 10 days is it requires more memory, and it's just more complicated to implement and is computationally more expensive. So for things, we'll see some examples on the next few videos, where you need to compute averages of a lot of variables. This is a very efficient way to do so both from computation and memory efficiency point of view which is why it's used in a lot of machine learning. Not to mention that there's just one line of code which is, maybe, another advantage. So, now, you know how to implement exponentially weighted averages. There's one more technical detail that's worth for you knowing about called bias correction. Let's see that in the next video, and then after that, you will use this to build a better optimization algorithm than the straight forward create\n\nBias Correction in Exponentially Weighted Averages\nYou've learned how to implement exponentially weighted averages. There's one technical detail called bias correction that can make your computation of these averages more accurate. Let's see how that works. In the previous video, you saw this figure for Beta equals 0.9, this figure for a Beta equals 0.98. But it turns out that if you implement the formula as written here, you won't actually get the green curve when Beta equals 0.98, you actually get the purple curve here. You notice that the purple curve starts off really low. Let's see how to fix that. When implementing a moving average, you initialize it with V_0 equals 0, and then V_1 is equal to 0.98 V_0 plus 0.02 Theta 1. But V_0 is equal to 0, so that term just goes away. So V_1 is just 0.02 times Theta 1. That's why if the first day's temperature is, say, 40 degrees Fahrenheit, then V_1 will be 0.02 times 40, which is 0.8, so you get a much lower value down here. That's not a very good estimate of the first day's temperature. V_2 will be 0.98 times V_1 plus 0.02 times Theta 2. If you plug in V_1, which is this down here, and multiply it out, then you find that V_2 is actually equal to 0.98 times 0.02 times Theta 1 plus 0.02 times Theta 2 and that's 0.0196 Theta 1 plus 0.02 Theta 2. Assuming Theta 1 and Theta 2 are positive numbers. When you compute this, V_2 will be much less than Theta 1 or Theta 2, so V_2 isn't a very good estimate of the first two days temperature of the year. It turns out that there's a way to modify this estimate that makes it much better, that makes it more accurate, especially during this initial phase of your estimate. Instead of taking V_t, take V_t divided by 1 minus Beta to the power of t, where t is the current day that you're on. Let's take a concrete example. When t is equal to 2, 1 minus Beta to the power of t is 1 minus 0.98 squared. It turns out that is 0.0396. Your estimate of the temperature on day 2 becomes V_2 divided by 0.0396, and this is going to be 0.0196 times Theta 1 plus 0.02 Theta 2. You notice that these two things act as denominator, 0.0396. This becomes a weighted average of Theta 1 and Theta 2 and this removes this bias. You notice that as t becomes large, Beta to the t will approach 0, which is why when t is large enough, the bias correction makes almost no difference. This is why when t is large, the purple line and the green line pretty much overlap. But during this initial phase of learning, when you're still warming up your estimates, bias correction can help you obtain a better estimate of the temperature. This is bias correction that helps you go from the purple line to the green line. In machine learning, for most implementations of the exponentially weighted average, people don't often bother to implement bias corrections because most people would rather just weigh that initial period and have a slightly more biased assessment and then go from there. But we are concerned about the bias during this initial phase, while your exponentially weighted moving average is warming up, then bias correction can help you get a better estimate early on. With that, you now know how to implement exponentially weighted moving averages. Let's go on and use this to build some better optimization algorithms.\n\nGradient Descent with Momentum\nThere's an algorithm called momentum, or gradient descent with momentum that almost always works faster than the standard gradient descent algorithm. In one sentence, the basic idea is to compute an exponentially weighted average of your gradients, and then use that gradient to update your weights instead. In this video, let's unpack that one-sentence description and see how you can actually implement this. As a example let's say that you're trying to optimize a cost function which has contours like this. So the red dot denotes the position of the minimum. Maybe you start gradient descent here and if you take one iteration of gradient descent either or descent maybe end up heading there. But now you're on the other side of this ellipse, and if you take another step of gradient descent maybe you end up doing that. And then another step, another step, and so on. And you see that gradient descents will sort of take a lot of steps, right? Just slowly oscillate toward the minimum. And this up and down oscillations slows down gradient descent and prevents you from using a much larger learning rate. In particular, if you were to use a much larger learning rate you might end up over shooting and end up diverging like so. And so the need to prevent the oscillations from getting too big forces you to use a learning rate that's not itself too large. Another way of viewing this problem is that on the vertical axis you want your learning to be a bit slower, because you don't want those oscillations. But on the horizontal axis, you want faster learning.\nRight, because you want it to aggressively move from left to right, toward that minimum, toward that red dot. So here's what you can do if you implement gradient descent with momentum.\nOn each iteration, or more specifically, during iteration t you would compute the usual derivatives dw, db. I'll omit the superscript square bracket l's but you compute dw, db on the current mini-batch. And if you're using batch gradient descent, then the current mini-batch would be just your whole batch. And this works as well off a batch gradient descent. So if your current mini-batch is your entire training set, this works fine as well. And then what you do is you compute vdW to be Beta vdw plus 1 minus Beta dW. So this is similar to when we're previously computing the theta equals beta v theta plus 1 minus beta theta t.\nRight, so it's computing a moving average of the derivatives for w you're getting. And then you similarly compute vdb equals that plus 1 minus Beta times db. And then you would update your weights using W gets updated as W minus the learning rate times, instead of updating it with dW, with the derivative, you update it with vdW. And similarly, b gets updated as b minus alpha times vdb. So what this does is smooth out the steps of gradient descent.\nFor example, let's say that in the last few derivatives you computed were this, this, this, this, this.\nIf you average out these gradients, you find that the oscillations in the vertical direction will tend to average out to something closer to zero. So, in the vertical direction, where you want to slow things down, this will average out positive and negative numbers, so the average will be close to zero. Whereas, on the horizontal direction, all the derivatives are pointing to the right of the horizontal direction, so the average in the horizontal direction will still be pretty big. So that's why with this algorithm, with a few iterations you find that the gradient descent with momentum ends up eventually just taking steps that are much smaller oscillations in the vertical direction, but are more directed to just moving quickly in the horizontal direction. And so this allows your algorithm to take a more straightforward path, or to damp out the oscillations in this path to the minimum. One intuition for this momentum which works for some people, but not everyone is that if you're trying to minimize your bowl shape function, right? This is really the contours of a bowl. I guess I'm not very good at drawing. They kind of minimize this type of bowl shaped function then these derivative terms you can think of as providing acceleration to a ball that you're rolling down hill. And these momentum terms you can think of as representing the velocity.\nAnd so imagine that you have a bowl, and you take a ball and the derivative imparts acceleration to this little ball as the little ball is rolling down this hill, right? And so it rolls faster and faster, because of acceleration. And data, because this number a little bit less than one, displays a row of friction and it prevents your ball from speeding up without limit. But so rather than gradient descent, just taking every single step independently of all previous steps. Now, your little ball can roll downhill and gain momentum, but it can accelerate down this bowl and therefore gain momentum. I find that this ball rolling down a bowl analogy, it seems to work for some people who enjoy physics intuitions. But it doesn't work for everyone, so if this analogy of a ball rolling down the bowl doesn't work for you, don't worry about it. Finally, let's look at some details on how you implement this. Here's the algorithm and so you now have two\nhyperparameters of the learning rate alpha, as well as this parameter Beta, which controls your exponentially weighted average. The most common value for Beta is 0.9. We're averaging over the last ten days temperature. So it is averaging of the last ten iteration's gradients. And in practice, Beta equals 0.9 works very well. Feel free to try different values and do some hyperparameter search, but 0.9 appears to be a pretty robust value. Well, and how about bias correction, right? So do you want to take vdW and vdb and divide it by 1 minus beta to the t. In practice, people don't usually do this because after just ten iterations, your moving average will have warmed up and is no longer a bias estimate. So in practice, I don't really see people bothering with bias correction when implementing gradient descent or momentum. And of course, this process initialize the vdW equals 0. Note that this is a matrix of zeroes with the same dimension as dW, which has the same dimension as W. And Vdb is also initialized to a vector of zeroes. So, the same dimension as db, which in turn has same dimension as b. Finally, I just want to mention that if you read the literature on gradient descent with momentum often you see it with this term omitted, with this 1 minus Beta term omitted. So you end up with vdW equals Beta vdw plus dW. And the net effect of using this version in purple is that vdW ends up being scaled by a factor of 1 minus Beta, or really 1 over 1 minus Beta. And so when you're performing these gradient descent updates, alpha just needs to change by a corresponding value of 1 over 1 minus Beta. In practice, both of these will work just fine, it just affects what's the best value of the learning rate alpha. But I find that this particular formulation is a little less intuitive. Because one impact of this is that if you end up tuning the hyperparameter Beta, then this affects the scaling of vdW and vdb as well. And so you end up needing to retune the learning rate, alpha, as well, maybe. So I personally prefer the formulation that I have written here on the left, rather than leaving out the 1 minus Beta term. But, so I tend to use the formula on the left, the printed formula with the 1 minus Beta term. But both versions having Beta equal 0.9 is a common choice of hyperparameter. It's just at alpha the learning rate would need to be tuned differently for these two different versions. So that's it for gradient descent with momentum. This will almost always work better than the straightforward gradient descent algorithm without momentum. But there's still other things we could do to speed up your learning algorithm. Let's continue talking about these in the next couple videos.\n\nRMSprop\nYou've seen how using momentum can speed up gradient descent. There's another algorithm called RMSprop, which stands for root mean square prop, that can also speed up gradient descent. Let's see how it works. Recall our example from before, that if you implement gradient descent, you can end up with huge oscillations in the vertical direction, even while it's trying to make progress in the horizontal direction. In order to provide intuition for this example, let's say that the vertical axis is the parameter b and horizontal axis is the parameter w. It could be w1 and w2 where some of the center parameters was named as b and w for the sake of intuition. And so, you want to slow down the learning in the b direction, or in the vertical direction. And speed up learning, or at least not slow it down in the horizontal direction. So this is what the RMSprop algorithm does to accomplish this. On iteration t, it will compute as usual the derivative dW, db on the current mini-batch.\nSo I was going to keep this exponentially weighted average. Instead of VdW, I'm going to use the new notation SdW. So SdW is equal to beta times their previous value + 1- beta times dW squared. Sometimes write this dW star star 2, to deliniate expensation we will just write this as dw squared. So for clarity, this squaring operation is an element-wise squaring operation. So what this is doing is really keeping an exponentially weighted average of the squares of the derivatives. And similarly, we also have Sdb equals beta Sdb + 1- beta, db squared. And again, the squaring is an element-wise operation. Next, RMSprop then updates the parameters as follows. W gets updated as W minus the learning rate, and whereas previously we had alpha times dW, now it's dW divided by square root of SdW. And b gets updated as b minus the learning rate times, instead of just the gradient, this is also divided by, now divided by Sdb.\nSo let's gain some intuition about how this works. Recall that in the horizontal direction or in this example, in the W direction we want learning to go pretty fast. Whereas in the vertical direction or in this example in the b direction, we want to slow down all the oscillations into the vertical direction. So with this terms SdW an Sdb, what we're hoping is that SdW will be relatively small, so that here we're dividing by relatively small number. Whereas Sdb will be relatively large, so that here we're dividing yt relatively large number in order to slow down the updates on a vertical dimension. And indeed if you look at the derivatives, these derivatives are much larger in the vertical direction than in the horizontal direction. So the slope is very large in the b direction, right? So with derivatives like this, this is a very large db and a relatively small dw. Because the function is sloped much more steeply in the vertical direction than as in the b direction, than in the w direction, than in horizontal direction. And so, db squared will be relatively large. So Sdb will relatively large, whereas compared to that dW will be smaller, or dW squared will be smaller, and so SdW will be smaller. So the net effect of this is that your up days in the vertical direction are divided by a much larger number, and so that helps damp out the oscillations. Whereas the updates in the horizontal direction are divided by a smaller number. So the net impact of using RMSprop is that your updates will end up looking more like this.\nThat your updates in the, Vertical direction and then horizontal direction you can keep going. And one effect of this is also that you can therefore use a larger learning rate alpha, and get faster learning without diverging in the vertical direction. Now just for the sake of clarity, I've been calling the vertical and horizontal directions b and w, just to illustrate this. In practice, you're in a very high dimensional space of parameters, so maybe the vertical dimensions where you're trying to damp the oscillation is a sum set of parameters, w1, w2, w17. And the horizontal dimensions might be w3, w4 and so on, right?. And so, the separation there's a WMP is just an illustration. In practice, dW is a very high-dimensional parameter vector. Db is also very high-dimensional parameter vector, but your intuition is that in dimensions where you're getting these oscillations, you end up computing a larger sum. A weighted average for these squares and derivatives, and so you end up dumping ] out the directions in which there are these oscillations. So that's RMSprop, and it stands for root mean squared prop, because here you're squaring the derivatives, and then you take the square root here at the end. So finally, just a couple last details on this algorithm before we move on.\nIn the next video, we're actually going to combine RMSprop together with momentum. So rather than using the hyperparameter beta, which we had used for momentum, I'm going to call this hyperparameter beta 2 just to not clash. The same hyperparameter for both momentum and for RMSprop. And also to make sure that your algorithm doesn't divide by 0. What if square root of SdW, right, is very close to 0. Then things could blow up. Just to ensure numerical stability, when you implement this in practice you add a very, very small epsilon to the denominator. It doesn't really matter what epsilon is used. 10 to the -8 would be a reasonable default, but this just ensures slightly greater numerical stability that for numerical round off or whatever reason, that you don't end up dividing by a very, very small number. So that's RMSprop, and similar to momentum, has the effects of damping out the oscillations in gradient descent, in mini-batch gradient descent. And allowing you to maybe use a larger learning rate alpha. And certainly speeding up the learning speed of your algorithm. So now you know to implement RMSprop, and this will be another way for you to speed up your learning algorithm. One fun fact about RMSprop, it was actually first proposed not in an academic research paper, but in a Coursera course that Jeff Hinton had taught on Coursera many years ago. I guess Coursera wasn't intended to be a platform for dissemination of novel academic research, but it worked out pretty well in that case. And was really from the Coursera course that RMSprop started to become widely known and it really took off. We talked about momentum. We talked about RMSprop. It turns out that if you put them together you can get an even better optimization algorithm. Let's talk about that in the next video.\n\nAdam Optimization Algorithm\nDuring the history of deep learning, many researchers including some very well-known researchers, sometimes proposed optimization algorithms and show they work well in a few problems. But those optimization algorithms subsequently were shown not to really generalize that well to the wide range of neural networks you might want to train. Over time, I think the deep learning community actually developed some amount of skepticism about new optimization algorithms. A lot of people felt that gradient descent with momentum really works well, was difficult to propose things that work much better. RMSprop and the Adam optimization algorithm, which we'll talk about in this video, is one of those rare algorithms that has really stood up, and has been shown to work well across a wide range of deep learning architectures. This one of the algorithms that I wouldn't hesitate to recommend you try, because many people have tried it and seeing it work well on many problems. The Adam optimization algorithm is basically taking momentum and RMSprop, and putting them together. Let's see how that works. To implement Adam, you initialize V_dw equals 0, S_dw equals 0, and similarly V_db, S_db equals 0. Then on iteration t, you would compute the derivatives, compute dw, db using current mini-batch. Usually, you do this with mini-batch gradient descent, and then you do the momentum exponentially weighted average. V_dw equals Beta, but now I'm going to call this Beta_1 to distinguish it from the hyperparameter, Beta_2 we'll use for the RMSprop portion of this. This is exactly what we had when we're implementing momentum except they have now called the hyperparameter Beta _1 instead of Beta, and similarly you have V_db as follows, plus 1 minus Beta_1 times db, and then you do the RMSprop, like update as well. Now you have a different hyperparameter, Beta_2, plus 1, minus Beta_2 dw squared. Again, the squaring there, is element-wise squaring of your derivatives, dw. Then S_db is equal to this, plus 1 minus Beta_2, times db. This is the momentum-like update with hyperparameter Beta_1, and this is the RMSprop-like update with hyperparameter Beta_2. In the typical implementation of Adam, you do implement bias correction. You're going to have V corrected, corrected means after bias correction, dw equals V_dw, divided by 1 minus Beta_1 ^t, if you've done t elevations, and similarly, V_db corrected equals V_db divided by 1 minus Beta_1^t, and then similarly you implement this bias correction on S as well, so there's S_dw, divided by 1 minus Beta_2^t, and S_ db corrected equals S_db divided by 1 minus Beta_2^t. Finally, you perform the update. W gets updated as W minus Alpha times. If we're just implementing momentum, you'd use V_dw, or maybe V_dw corrected. But now we add in the RMSprop portion of this, so we're also going to divide by square root of S_dw corrected, plus Epsilon, and similarly, b gets updated as a similar formula. V_db corrected divided by square root S corrected, db plus Epsilon. These algorithm combines the effect of gradient descent with momentum together with gradient descent with RMSprop. This is commonly used learning algorithm that's proven to be very effective for many different neural networks of a very wide variety of architectures. This algorithm has a number of hyperparameters. The learning rate hyperparameter Alpha is still important, and usually needs to be tuned, so you just have to try a range of values and see what works. We did a default choice for Beta _1 is 0.9, so this is the weighted average of dw. This is the momentum-like term. The hyperparameter for Beta_2, the authors of the Adam paper inventors the Adam algorithm recommend 0.999. Again, this is computing the moving weighted average of dw squared as was db squared. The choice of Epsilon doesn't matter very much, but the authors of the Adam paper recommend a 10^minus 8, but this parameter, you really don't need to set it, and it doesn't affect performance much at all. But when implementing Adam, what people usually do is just use a default values of Beta_1 and Beta _2, as was Epsilon. I don't think anyone ever really tuned Epsilon, and then try a range of values of Alpha to see what works best. You can also tune Beta_1 and Beta_2, but is not done that often among the practitioners I know. Where does the term Adam come from? Adam stands for adaptive moment estimation, so Beta_1 is computing the mean of the derivatives. This is called the first moment, and Beta_2 is used to compute exponentially weighted average of the squares, and that's called the second moment. That gives rise to the name adaptive moment estimation. But everyone just calls it the Adam optimization algorithm. By the way, one of my long-term friends and collaborators is called Adam Coates. Far as I know, this algorithm doesn't have anything to do with him, except for the fact that I think he uses it sometimes, but sometimes I get asked that question. Just in case you're wondering. That's it for the Adam optimization algorithm. With it, I think you really train your neural networks much more quickly. But before we wrap up for this week, let's keep talking about hyperparameter tuning, as well as gain some more intuitions about what the optimization problem for neural networks looks like. In the next video, we'll talk about learning rate decay.\n\nLearning Rate Decay\nOne of the things that might help speed up your learning algorithm is to slowly reduce your learning rate over time. We call this learning rate decay. Let's see how you can implement this. Let's start with an example of why you might want to implement learning rate decay. Suppose you're implementing mini-batch gradient descents with a reasonably small mini-batch, maybe a mini-batch has just 64, 128 examples. Then as you iterate, your steps will be a little bit noisy and it will tend towards this minimum over here, but it won't exactly converge. But your algorithm might just end up wandering around and never really converge because you're using some fixed value for Alpha and there's just some noise in your different mini-batches. But if you were to slowly reduce your learning rate Alpha, then during the initial phases, while your learning rate Alpha is still large, you can still have relatively fast learning. But then as Alpha gets smaller, your steps you take will be slower and smaller, and so, you end up oscillating in a tighter region around this minimum rather than wandering far away even as training goes on and on. The intuition behind slowly reducing Alpha is that maybe during the initial steps of learning, you could afford to take much bigger steps, but then as learning approaches convergence, then having a slower learning rate allows you to take smaller steps. Here's how you can implement learning rate decay. Recall that one epoch is one pass through the data. If you have a training set as follows, maybe break it up into different mini-batches. Then the first pass through the training set is called the first epoch, and then the second pass is the second epoch, and so on. One thing you could do is set your learning rate Alpha to be equal to 1 over 1 plus a parameter, which I'm going to call the decay rate, times the epoch num. This is going to be times some initial learning rate Alpha 0. Note that the decay rate here becomes another hyperparameter which you might need to tune. Here's a concrete example. If you take several epochs, so several passes through your data, if Alpha 0 is equal to 0.2 and the decay rate is equal to 1, then during your first epoch, Alpha will be 1 over 1 plus 1 times Alpha 0, so your learning rate will be 0.1. That's just evaluating this formula when the decay rate is equal to 1 and epoch num is 1. On the second epoch, your learning rate decay is 0.67. On the third, 0.5. On the fourth, 0.4, and so on. Feel free to evaluate more of these values yourself and get a sense that as a function of epoch number, your learning rate gradually decreases, according to this formula up on top. If you wish to use learning rate decay, what you can do is try a variety of values of both hyperparameter Alpha 0, as well as this decay rate hyperparameter, and then try to find a value that works well. Other than this formula for learning rate decay, there are a few other ways that people use. For example, this is called exponential decay, where Alpha is equal to some number less than 1, such as 0.95, times epoch num times Alpha 0. This will exponentially quickly decay your learning rate. Other formulas that people use are things like Alpha equals some constant over epoch num square root times Alpha 0, or some constant k and another hyperparameter over the mini-batch number t square rooted times Alpha 0. Sometimes you also see people use a learning rate that decreases and discretes that, where for some number of steps, you have some learning rate, and then after a while, you decrease it by one-half, after a while, by one-half, after a while, by one-half, and so, this is a discrete staircase.\nSo far, we've talked about using some formula to govern how Alpha, the learning rate changes over time. One other thing that people sometimes do is manual decay. If you're training just one model at a time, and if your model takes many hours or even many days to train, what some people would do is just watch your model as it's training over a large number of days, and then now you say, oh, it looks like the learning rate slowed down, I'm going to decrease Alpha a little bit. Of course, this works, this manually controlling Alpha, really tuning Alpha by hand, hour-by-hour, day-by-day. This works only if you're training only a small number of models, but sometimes people do that as well. Now you have a few more options of how to control the learning rate Alpha. Now, in case you're thinking, wow, this is a lot of hyperparameters, how do I select amongst all these different options? I would say don't worry about it for now, and next week, we'll talk more about how to systematically choose hyperparameters. For me, I would say that learning rate decay is usually lower down on the list of things I try. Setting Alpha just a fixed value of Alpha and getting that to be well-tuned has a huge impact, learning rate decay does help. Sometimes it can really help speed up training, but it is a little bit lower down my list in terms of the things I would try. But next week, when we talk about hyperparameter tuning, you'll see more systematic ways to organize all of these hyperparameters and how to efficiently search amongst them. That's it for learning rate decay. Finally, I also want to talk a little bit about local optima and saddle points in neural networks so you can have a little bit better intuition about the types of optimization problems your optimization algorithm is trying to solve when you're trying to train these neural networks. Let's go onto the next video to see that.\n\nThe Problem of Local Optima\nIn the early days of deep learning, people used to worry a lot about the optimization algorithm getting stuck in bad local optima. But as this theory of deep learning has advanced, our understanding of local optima is also changing. Let me show you how we now think about local optima and problems in the optimization problem in deep learning. This was a picture people used to have in mind when they worried about local optima. Maybe you are trying to optimize some set of parameters, we call them W1 and W2, and the height in the surface is the cost function. In this picture, it looks like there are a lot of local optima in all those places. And it'd be easy for grading the sense, or one of the other algorithms to get stuck in a local optimum rather than find its way to a global optimum. It turns out that if you are plotting a figure like this in two dimensions, then it's easy to create plots like this with a lot of different local optima. And these very low dimensional plots used to guide their intuition. But this intuition isn't actually correct. It turns out if you create a neural network, most points of zero gradients are not local optima like points like this. Instead most points of zero gradient in a cost function are saddle points. So, that's a point where the zero gradient, again, just is maybe W1, W2, and the height is the value of the cost function J. But informally, a function of very high dimensional space, if the gradient is zero, then in each direction it can either be a convex light function or a concave light function. And if you are in, say, a 20,000 dimensional space, then for it to be a local optima, all 20,000 directions need to look like this. And so the chance of that happening is maybe very small, maybe two to the minus 20,000. Instead you're much more likely to get some directions where the curve bends up like so, as well as some directions where the curve function is bending down rather than have them all bend upwards. So that's why in very high-dimensional spaces you're actually much more likely to run into a saddle point like that shown on the right, then the local optimum. As for why the surface is called a saddle point, if you can picture, maybe this is a sort of saddle you put on a horse, right? Maybe this is a horse. This is a head of a horse, this is the eye of a horse. Well, not a good drawing of a horse but you get the idea. Then you, the rider, will sit here in the saddle. That's why this point here, where the derivative is zero, that point is called a saddle point. There's really the point on this saddle where you would sit, I guess, and that happens to have derivative zero. And so, one of the lessons we learned in history of deep learning is that a lot of our intuitions about low-dimensional spaces, like what you can plot on the left, they really don't transfer to the very high-dimensional spaces that any other algorithms are operating over. Because if you have 20,000 parameters, then J as your function over 20,000 dimensional vector, then you're much more likely to see saddle points than local optimum. If local optima aren't a problem, then what is a problem? It turns out that plateaus can really slow down learning and a plateau is a region where the derivative is close to zero for a long time. So if you're here, then gradient descents will move down the surface, and because the gradient is zero or near zero, the surface is quite flat. You can actually take a very long time, you know, to slowly find your way to maybe this point on the plateau. And then because of a random perturbation of left or right, maybe then finally I'm going to search pen colors for clarity. Your algorithm can then find its way off the plateau. Let it take this very long slope off before it's found its way here and they could get off this plateau. So the takeaways from this video are, first, you're actually pretty unlikely to get stuck in bad local optima so long as you're training a reasonably large neural network, save a lot of parameters, and the cost function J is defined over a relatively high dimensional space. But second, that plateaus are a problem and you can actually make learning pretty slow. And this is where algorithms like momentum or RmsProp or Adam can really help your learning algorithm as well. And these are scenarios where more sophisticated observation algorithms, such as Adam, can actually speed up the rate at which you could move down the plateau and then get off the plateau. So because your network is solving optimizations problems over such high dimensional spaces, to be honest, I don't think anyone has great intuitions about what these spaces really look like, and our understanding of them is still evolving. But I hope this gives you some better intuition about the challenges that the optimization algorithms may face. So that's congratulations on coming to the end of this week's content. Please take a look at this week's quiz as well as the exercise. I hope you enjoy practicing some of these ideas of this weeks exercise and I look forward to seeing you at the start of next week's videos.\n", "source": "coursera_c", "evaluation": "exam"}
{"instructions": ["Question 1. Softmax regression is a generalization of logistic regression to:\nA. More than two features\nB. More than two hidden layers\nC. More than two activation functions\nD. More than two classes", "Question 2. The loss function for Softmax regression can not be defined as:\nA. Mean squared error\nB. Cross-entropy loss\nC. Hinge loss\nD. Log-cosh loss", "Question 3. During training, Batch Normalization computes the mean and variance of Z on:\nA. The entire training set\nB. A single example\nC. A mini-batch\nD. A single layer", "Question 4. At test time, when using Batch Normalization, you should NOT:\nA. Compute the mean and variance of Z on the entire test set\nB. Use the mean and variance of Z computed during training on mini-batches\nC. Compute the mean and variance of Z on a single test example\nD. Use a separate estimate of \\mu and \\sigma squared from the training set", "Question 5. Batch Normalization has a regularization effect because:\nA. It adds noise to the hidden layers\nB. It reduces the number of parameters in the model\nC. It forces the model to use fewer hidden layers\nD. It increases the learning rate", "Question 6. When using a Softmax layer, the decision boundary between any two classes will NOT be:\nA. Non-linear\nB. Linear\nC. Quadratic\nD. Exponential", "Question 7. In Softmax regression, if C = 2, then Softmax with C = 2 essentially reduces to:\nA. Linear regression\nB. Logistic regression\nC. Support vector machine\nD. Decision tree", "Question 8. The key equation you need to initialize backpropagation in a Softmax output layer is:\nA. dZ[L] = A[L] - Y\nB. dZ[L] = Z[L] - Y\nC. dZ[L] = Y_hat - Y\nD. dZ[L] = Y - Y_hat", "Question 9. Which of these statements about deep learning programming frameworks are true? (Check all that apply)\nA. A programming framework allows you to code up deep learning algorithms with typically fewer lines of code than a lower-level language such as Python.\nB. Deep learning programming frameworks require cloud-based machines to run.\nC. Even if a project is currently open source, good governance of the project helps ensure that the it remains open even in the long term, rather than become closed or modified to benefit only one company.\nD. Deep learning programming frameworks only support Supervised Learning tasks, and not Unsupervised Learning or Reinforcement Learning tasks."], "outputs": ["D", "ACD", "C", "ABC", "A", "ACD", "B", "A", "AC"], "input": "Tuning Process\nHi, and welcome back. You've seen by now that changing neural nets can involve setting a lot of different hyperparameters. Now, how do you go about finding a good setting for these hyperparameters? In this video, I want to share with you some guidelines, some tips for how to systematically organize your hyperparameter tuning process, which hopefully will make it more efficient for you to converge on a good setting of the hyperparameters. One of the painful things about training deepness is the sheer number of hyperparameters you have to deal with, ranging from the learning rate alpha to the momentum term beta, if using momentum, or the hyperparameters for the Adam Optimization Algorithm which are beta one, beta two, and epsilon. Maybe you have to pick the number of layers, maybe you have to pick the number of hidden units for the different layers, and maybe you want to use learning rate decay, so you don't just use a single learning rate alpha. And then of course, you might need to choose the mini-batch size. So it turns out, some of these hyperparameters are more important than others. The most learning applications I would say, alpha, the learning rate is the most important hyperparameter to tune. Other than alpha, a few other hyperparameters I tend to would maybe tune next, would be maybe the momentum term, say, 0.9 is a good default. I'd also tune the mini-batch size to make sure that the optimization algorithm is running efficiently. Often I also fiddle around with the hidden units. Of the ones I've circled in orange, these are really the three that I would consider second in importance to the learning rate alpha, and then third in importance after fiddling around with the others, the number of layers can sometimes make a huge difference, and so can learning rate decay. And then, when using the Adam algorithm I actually pretty much never tuned beta one, beta two, and epsilon. Pretty much I always use 0.9, 0.999 and tenth minus eight although you can try tuning those as well if you wish. But hopefully it does give you some rough sense of what hyperparameters might be more important than others, alpha, most important, for sure, followed maybe by the ones I've circle in orange, followed maybe by the ones I circled in purple. But this isn't a hard and fast rule and I think other deep learning practitioners may well disagree with me or have different intuitions on these. Now, if you're trying to tune some set of hyperparameters, how do you select a set of values to explore? In earlier generations of machine learning algorithms, if you had two hyperparameters, which I'm calling hyperparameter one and hyperparameter two here, it was common practice to sample the points in a grid like so, and systematically explore these values. Here I am placing down a five by five grid. In practice, it could be more or less than the five by five grid but you try out in this example all 25 points, and then pick whichever hyperparameter works best. And this practice works okay when the number of hyperparameters was relatively small. In deep learning, what we tend to do, and what I recommend you do instead, is choose the points at random. So go ahead and choose maybe of same number of points, right? 25 points, and then try out the hyperparameters on this randomly chosen set of points. And the reason you do that is that it's difficult to know in advance which hyperparameters are going to be the most important for your problem. And as you saw in the previous slide, some hyperparameters are actually much more important than others. So to take an example, let's say hyperparameter one turns out to be alpha, the learning rate. And to take an extreme example, let's say that hyperparameter two was that value epsilon that you have in the denominator of the Adam algorithm. So your choice of alpha matters a lot and your choice of epsilon hardly matters. So if you sample in the grid then you've really tried out five values of alpha and you might find that all of the different values of epsilon give you essentially the same answer. So you've now trained 25 models and only got into trial five values for the learning rate alpha, which I think is really important. Whereas in contrast, if you were to sample at random, then you will have tried out 25 distinct values of the learning rate alpha and therefore you be more likely to find a value that works really well. I've explained this example, using just two hyperparameters. In practice, you might be searching over many more hyperparameters than these, so if you have, say, three hyperparameters, I guess instead of searching over a square, you're searching over a cube where this third dimension is hyperparameter three and then by sampling within this three-dimensional cube you get to try out a lot more values of each of your three hyperparameters. And in practice you might be searching over even more hyperparameters than three and sometimes it's just hard to know in advance which ones turn out to be the really important hyperparameters for your application and sampling at random rather than in the grid shows that you are more richly exploring set of possible values for the most important hyperparameters, whatever they turn out to be. When you sample hyperparameters, another common practice is to use a coarse to fine sampling scheme. So let's say in this two-dimensional example that you sample these points, and maybe you found that this point work the best and maybe a few other points around it tended to work really well, then in the course of the final scheme what you might do is zoom in to a smaller region of the hyperparameters, and then sample more density within this space. Or maybe again at random, but to then focus more resources on searching within this blue square if you're suspecting that the best setting, the hyperparameters, may be in this region. So after doing a coarse sample of this entire square, that tells you to then focus on a smaller square. You can then sample more densely into smaller square. So this type of a coarse to fine search is also frequently used. And by trying out these different values of the hyperparameters you can then pick whatever value allows you to do best on your training set objective, or does best on your development set, or whatever you're trying to optimize in your hyperparameter search process. So I hope this gives you a way to more systematically organize your hyperparameter search process. The two key takeaways are, use random sampling and adequate search and optionally consider implementing a coarse to fine search process. But there's even more to hyperparameter search than this. Let's talk more in the next video about how to choose the right scale on which to sample your hyperparameters.\n\nUsing an Appropriate Scale to pick Hyperparameters\nIn the last video, you saw how sampling at random, over the range of hyperparameters, can allow you to search over the space of hyperparameters more efficiently. But it turns out that sampling at random doesn't mean sampling uniformly at random, over the range of valid values. Instead, it's important to pick the appropriate scale on which to explore the hyperparameters. In this video, I want to show you how to do that. Let's say that you're trying to choose the number of hidden units, n[l], for a given layer l. And let's say that you think a good range of values is somewhere from 50 to 100. In that case, if you look at the number line from 50 to 100, maybe picking some number values at random within this number line. There's a pretty visible way to search for this particular hyperparameter. Or if you're trying to decide on the number of layers in your neural network, we're calling that capital L. Maybe you think the total number of layers should be somewhere between 2 to 4. Then sampling uniformly at random, along 2, 3 and 4, might be reasonable. Or even using a grid search, where you explicitly evaluate the values 2, 3 and 4 might be reasonable. So these were a couple examples where sampling uniformly at random over the range you're contemplating; might be a reasonable thing to do. But this is not true for all hyperparameters. Let's look at another example. Say your searching for the hyperparameter alpha, the learning rate. And let's say that you suspect 0.0001 might be on the low end, or maybe it could be as high as 1. Now if you draw the number line from 0.0001 to 1, and sample values uniformly at random over this number line. Well about 90% of the values you sample would be between 0.1 and 1. So you're using 90% of the resources to search between 0.1 and 1, and only 10% of the resources to search between 0.0001 and 0.1. So that doesn't seem right. Instead, it seems more reasonable to search for hyperparameters on a log scale. Where instead of using a linear scale, you'd have 0.0001 here, and then 0.001, 0.01, 0.1, and then 1. And you instead sample uniformly, at random, on this type of logarithmic scale. Now you have more resources dedicated to searching between 0.0001 and 0.001, and between 0.001 and 0.01, and so on. So in Python, the way you implement this,\nis let r = -4 * np.random.rand(). And then a randomly chosen value of alpha, would be alpha = 10 to the power of r.\nSo after this first line, r will be a random number between -4 and 0. And so alpha here will be between 10 to the -4 and 10 to the 0. So 10 to the -4 is this left thing, this 10 to the -4. And 1 is 10 to the 0. In a more general case, if you're trying to sample between 10 to the a, to 10 to the b, on the log scale. And in this example, this is 10 to the a. And you can figure out what a is by taking the log base 10 of 0.0001, which is going to tell you a is -4. And this value on the right, this is 10 to the b. And you can figure out what b is, by taking log base 10 of 1, which tells you b is equal to 0.\nSo what you do, is then sample r uniformly, at random, between a and b. So in this case, r would be between -4 and 0. And you can set alpha, on your randomly sampled hyperparameter value, as 10 to the r, okay? So just to recap, to sample on the log scale, you take the low value, take logs to figure out what is a. Take the high value, take a log to figure out what is b. So now you're trying to sample, from 10 to the a to the b, on a log scale. So you set r uniformly, at random, between a and b. And then you set the hyperparameter to be 10 to the r. So that's how you implement sampling on this logarithmic scale. Finally, one other tricky case is sampling the hyperparameter beta, used for computing exponentially weighted averages. So let's say you suspect that beta should be somewhere between 0.9 to 0.999. Maybe this is the range of values you want to search over. So remember, that when computing exponentially weighted averages, using 0.9 is like averaging over the last 10 values. kind of like taking the average of 10 days temperature, whereas using 0.999 is like averaging over the last 1,000 values. So similar to what we saw on the last slide, if you want to search between 0.9 and 0.999, it doesn't make sense to sample on the linear scale, right? Uniformly, at random, between 0.9 and 0.999. So the best way to think about this, is that we want to explore the range of values for 1 minus beta, which is going to now range from 0.1 to 0.001. And so we'll sample the between beta, taking values from 0.1, to maybe 0.1, to 0.001. So using the method we have figured out on the previous slide, this is 10 to the -1, this is 10 to the -3. Notice on the previous slide, we had the small value on the left, and the large value on the right, but here we have reversed. We have the large value on the left, and the small value on the right. So what you do, is you sample r uniformly, at random, from -3 to -1. And you set 1- beta = 10 to the r, and so beta = 1- 10 to the r. And this becomes your randomly sampled value of your hyperparameter, chosen on the appropriate scale. And hopefully this makes sense, in that this way, you spend as much resources exploring the range 0.9 to 0.99, as you would exploring 0.99 to 0.999. So if you want to study more formal mathematical justification for why we're doing this, right, why is it such a bad idea to sample in a linear scale? It is that, when beta is close to 1, the sensitivity of the results you get changes, even with very small changes to beta. So if beta goes from 0.9 to 0.9005, it's no big deal, this is hardly any change in your results. But if beta goes from 0.999 to 0.9995, this will have a huge impact on exactly what your algorithm is doing, right? In both of these cases, it's averaging over roughly 10 values. But here it's gone from an exponentially weighted average over about the last 1,000 examples, to now, the last 2,000 examples. And it's because that formula we have, 1 / 1- beta, this is very sensitive to small changes in beta, when beta is close to 1. So what this whole sampling process does, is it causes you to sample more densely in the region of when beta is close to 1.\nOr, alternatively, when 1- beta is close to 0. So that you can be more efficient in terms of how you distribute the samples, to explore the space of possible outcomes more efficiently. So I hope this helps you select the right scale on which to sample the hyperparameters. In case you don't end up making the right scaling decision on some hyperparameter choice, don't worry to much about it. Even if you sample on the uniform scale, where sum of the scale would have been superior, you might still get okay results. Especially if you use a coarse to fine search, so that in later iterations, you focus in more on the most useful range of hyperparameter values to sample. I hope this helps you in your hyperparameter search. In the next video, I also want to share with you some thoughts of how to organize your hyperparameter search process. That I hope will make your workflow a bit more efficient.\n\nHyperparameters Tuning in Practice: Pandas vs. Caviar\nYou have now heard a lot about how to search for good hyperparameters. Before wrapping up our discussion on hyperparameter search, I want to share with you just a couple of final tips and tricks for how to organize your hyperparameter search process. Deep learning today is applied to many different application areas and that intuitions about hyperparameter settings from one application area may or may not transfer to a different one. There is a lot of cross-fertilization among different applications' domains, so for example, I've seen ideas developed in the computer vision community, such as Confonets or ResNets, which we'll talk about in a later course, successfully applied to speech. I've seen ideas that were first developed in speech successfully applied in NLP, and so on. So one nice development in deep learning is that people from different application domains do read increasingly research papers from other application domains to look for inspiration for cross-fertilization. In terms of your settings for the hyperparameters, though, I've seen that intuitions do get stale. So even if you work on just one problem, say logistics, you might have found a good setting for the hyperparameters and kept on developing your algorithm, or maybe seen your data gradually change over the course of several months, or maybe just upgraded servers in your data center. And because of those changes, the best setting of your hyperparameters can get stale. So I recommend maybe just retesting or reevaluating your hyperparameters at least once every several months to make sure that you're still happy with the values you have. Finally, in terms of how people go about searching for hyperparameters, I see maybe two major schools of thought, or maybe two major different ways in which people go about it. One way is if you babysit one model. And usually you do this if you have maybe a huge data set but not a lot of computational resources, not a lot of CPUs and GPUs, so you can basically afford to train only one model or a very small number of models at a time. In that case you might gradually babysit that model even as it's training. So, for example, on Day 0 you might initialize your parameter as random and then start training. And you gradually watch your learning curve, maybe the cost function J or your dataset error or something else, gradually decrease over the first day. Then at the end of day one, you might say, gee, looks it's learning quite well, I'm going to try increasing the learning rate a little bit and see how it does. And then maybe it does better. And then that's your Day 2 performance. And after two days you say, okay, it's still doing quite well. Maybe I'll fill the momentum term a bit or decrease the learning variable a bit now, and then you're now into Day 3. And every day you kind of look at it and try nudging up and down your parameters. And maybe on one day you found your learning rate was too big. So you might go back to the previous day's model, and so on. But you're kind of babysitting the model one day at a time even as it's training over a course of many days or over the course of several different weeks. So that's one approach, and people that babysit one model, that is watching performance and patiently nudging the learning rate up or down. But that's usually what happens if you don't have enough computational capacity to train a lot of models at the same time. The other approach would be if you train many models in parallel. So you might have some setting of the hyperparameters and just let it run by itself ,either for a day or even for multiple days, and then you get some learning curve like that; and this could be a plot of the cost function J or cost of your training error or cost of your dataset error, but some metric in your tracking. And then at the same time you might start up a different model with a different setting of the hyperparameters. And so, your second model might generate a different learning curve, maybe one that looks like that. I will say that one looks better. And at the same time, you might train a third model, which might generate a learning curve that looks like that, and another one that, maybe this one diverges so it looks like that, and so on. Or you might train many different models in parallel, where these orange lines are different models, right, and so this way you can try a lot of different hyperparameter settings and then just maybe quickly at the end pick the one that works best. Looks like in this example it was, maybe this curve that look best. So to make an analogy, I'm going to call the approach on the left the panda approach. When pandas have children, they have very few children, usually one child at a time, and then they really put a lot of effort into making sure that the baby panda survives. So that's really babysitting. One model or one baby panda. Whereas the approach on the right is more like what fish do. I'm going to call this the caviar strategy. There's some fish that lay over 100 million eggs in one mating season. But the way fish reproduce is they lay a lot of eggs and don't pay too much attention to any one of them but just see that hopefully one of them, or maybe a bunch of them, will do well. So I guess, this is really the difference between how mammals reproduce versus how fish and a lot of reptiles reproduce. But I'm going to call it the panda approach versus the caviar approach, since that's more fun and memorable. So the way to choose between these two approaches is really a function of how much computational resources you have. If you have enough computers to train a lot of models in parallel,\nthen by all means take the caviar approach and try a lot of different hyperparameters and see what works. But in some application domains, I see this in some online advertising settings as well as in some computer vision applications, where there's just so much data and the models you want to train are so big that it's difficult to train a lot of models at the same time. It's really application dependent of course, but I've seen those communities use the panda approach a little bit more, where you are kind of babying a single model along and nudging the parameters up and down and trying to make this one model work. Although, of course, even the panda approach, having trained one model and then seen it work or not work, maybe in the second week or the third week, maybe I should initialize a different model and then baby that one along just like even pandas, I guess, can have multiple children in their lifetime, even if they have only one, or a very small number of children, at any one time. So hopefully this gives you a good sense of how to go about the hyperparameter search process. Now, it turns out that there's one other technique that can make your neural network much more robust to the choice of hyperparameters. It doesn't work for all neural networks, but when it does, it can make the hyperparameter search much easier and also make training go much faster. Let's talk about this technique in the next video.\n\nNormalizing Activations in a Network\nIn the rise of deep learning, one of the most important ideas has been an algorithm called batch normalization, created by two researchers, Sergey Ioffe and Christian Szegedy. Batch normalization makes your hyperparameter search problem much easier, makes your neural network much more robust. The choice of hyperparameters is a much bigger range of hyperparameters that work well, and will also enable you to much more easily train even very deep networks. Let's see how batch normalization works. When training a model, such as logistic regression, you might remember that normalizing the input features can speed up learnings in compute the means, subtract off the means from your training sets. Compute the variances.\nThe sum of xi squared. This is an element-wise squaring.\nAnd then normalize your data set according to the variances. And we saw in an earlier video how this can turn the contours of your learning problem from something that might be very elongated to something that is more round, and easier for an algorithm like gradient descent to optimize. So this works, in terms of normalizing the input feature values to a neural network, alter the regression. Now, how about a deeper model? You have not just input features x, but in this layer you have activations a1, in this layer, you have activations a2 and so on. So if you want to train the parameters, say w3, b3, then\nwouldn't it be nice if you can normalize the mean and variance of a2 to make the training of w3, b3 more efficient?\nIn the case of logistic regression, we saw how normalizing x1, x2, x3 maybe helps you train w and b more efficiently. So here, the question is, for any hidden layer, can we normalize,\nThe values of a, let's say a2, in this example but really any hidden layer, so as to train w3 b3 faster, right? Since a2 is the input to the next layer, that therefore affects your training of w3 and b3.\nSo this is what batch norm does, batch normalization, or batch norm for short, does. Although technically, we'll actually normalize the values of not a2 but z2. There are some debates in the deep learning literature about whether you should normalize the value before the activation function, so z2, or whether you should normalize the value after applying the activation function, a2. In practice, normalizing z2 is done much more often. So that's the version I'll present and what I would recommend you use as a default choice. So here is how you will implement batch norm. Given some intermediate values, In your neural net,\nLet's say that you have some hidden unit values z1 up to zm, and this is really from some hidden layer, so it'd be more accurate to write this as z for some hidden layer i for i equals 1 through m. But to reduce writing, I'm going to omit this [l], just to simplify the notation on this line. So given these values, what you do is compute the mean as follows. Okay, and all this is specific to some layer l, but I'm omitting the [l]. And then you compute the variance using pretty much the formula you would expect and then you would take each the zis and normalize it. So you get zi normalized by subtracting off the mean and dividing by the standard deviation. For numerical stability, we usually add epsilon to the denominator like that just in case sigma squared turns out to be zero in some estimate. And so now we've taken these values z and normalized them to have mean 0 and standard unit variance. So every component of z has mean 0 and variance 1. But we don't want the hidden units to always have mean 0 and variance 1. Maybe it makes sense for hidden units to have a different distribution, so what we'll do instead is compute, I'm going to call this z tilde = gamma zi norm + beta. And here, gamma and beta are learnable parameters of your model.\nSo we're using gradient descent, or some other algorithm, like the gradient descent of momentum, or rms proper atom, you would update the parameters gamma and beta, just as you would update the weights of your neural network. Now, notice that the effect of gamma and beta is that it allows you to set the mean of z tilde to be whatever you want it to be. In fact, if gamma equals square root sigma squared\nplus epsilon, so if gamma were equal to this denominator term. And if beta were equal to mu, so this value up here, then the effect of gamma z norm plus beta is that it would exactly invert this equation. So if this is true, then actually z tilde i is equal to zi. And so by an appropriate setting of the parameters gamma and beta, this normalization step, that is, these four equations is just computing essentially the identity function. But by choosing other values of gamma and beta, this allows you to make the hidden unit values have other means and variances as well. And so the way you fit this into your neural network is, whereas previously you were using these values z1, z2, and so on, you would now use z tilde i, Instead of zi for the later computations in your neural network. And you want to put back in this [l] to explicitly denote which layer it is in, you can put it back there. So the intuition I hope you'll take away from this is that we saw how normalizing the input features x can help learning in a neural network. And what batch norm does is it applies that normalization process not just to the input layer, but to the values even deep in some hidden layer in the neural network. So it will apply this type of normalization to normalize the mean and variance of some of your hidden units' values, z. But one difference between the training input and these hidden unit values is you might not want your hidden unit values be forced to have mean 0 and variance 1. For example, if you have a sigmoid activation function, you don't want your values to always be clustered here. You might want them to have a larger variance or have a mean that's different than 0, in order to better take advantage of the nonlinearity of the sigmoid function rather than have all your values be in just this linear regime. So that's why with the parameters gamma and beta, you can now make sure that your zi values have the range of values that you want. But what it does really is it then shows that your hidden units have standardized mean and variance, where the mean and variance are controlled by two explicit parameters gamma and beta which the learning algorithm can set to whatever it wants. So what it really does is it normalizes in mean and variance of these hidden unit values, really the zis, to have some fixed mean and variance. And that mean and variance could be 0 and 1, or it could be some other value, and it's controlled by these parameters gamma and beta. So I hope that gives you a sense of the mechanics of how to implement batch norm, at least for a single layer in the neural network. In the next video, I'm going to show you how to fit batch norm into a neural network, even a deep neural network, and how to make it work for the many different layers of a neural network. And after that, we'll get some more intuition about why batch norm could help you train your neural network. So in case why it works still seems a little bit mysterious, stay with me, and I think in two videos from now we'll really make that clearer.\n\nFitting Batch Norm into a Neural Network\nSo you have seen the equations for how to invent Batch Norm for maybe a single hidden layer. Let's see how it fits into the training of a deep network. So, let's say you have a neural network like this, you've seen me say before that you can view each of the unit as computing two things. First, it computes Z and then it applies the activation function to compute A. And so we can think of each of these circles as representing a two-step computation. And similarly for the next layer, that is Z2 1, and A2 1, and so on. So, if you were not applying Batch Norm, you would have an input X fit into the first hidden layer, and then first compute Z1, and this is governed by the parameters W1 and B1. And then ordinarily, you would fit Z1 into the activation function to compute A1. But what would do in Batch Norm is take this value Z1, and apply Batch Norm, sometimes abbreviated BN to it, and that's going to be governed by parameters, Beta 1 and Gamma 1, and this will give you this new normalize value Z1. And then you feed that to the activation function to get A1, which is G1 applied to Z tilde 1. Now, you've done the computation for the first layer, where this Batch Norms that really occurs in between the computation from Z and A. Next, you take this value A1 and use it to compute Z2, and so this is now governed by W2, B2. And similar to what you did for the first layer, you would take Z2 and apply it through Batch Norm, and we abbreviate it to BN now. This is governed by Batch Norm parameters specific to the next layer. So Beta 2, Gamma 2, and now this gives you Z tilde 2, and you use that to compute A2 by applying the activation function, and so on. So once again, the Batch Norms that happens between computing Z and computing A. And the intuition is that, instead of using the un-normalized value Z, you can use the normalized value Z tilde, that's the first layer. The second layer as well, instead of using the un-normalized value Z2, you can use the mean and variance normalized values Z tilde 2. So the parameters of your network are going to be W1, B1. It turns out we'll get rid of the parameters but we'll see why in the next slide. But for now, imagine the parameters are the usual W1. B1, WL, BL, and we have added to this new network, additional parameters Beta 1, Gamma 1, Beta 2, Gamma 2, and so on, for each layer in which you are applying Batch Norm. For clarity, note that these Betas here, these have nothing to do with the hyperparameter beta that we had for momentum over the computing the various exponentially weighted averages. The authors of the Adam paper use Beta on their paper to denote that hyperparameter, the authors of the Batch Norm paper had used Beta to denote this parameter, but these are two completely different Betas. I decided to stick with Beta in both cases, in case you read the original papers. But the Beta 1, Beta 2, and so on, that Batch Norm tries to learn is a different Beta than the hyperparameter Beta used in momentum and the Adam and RMSprop algorithms. So now that these are the new parameters of your algorithm, you would then use whether optimization you want, such as creating descent in order to implement it. For example, you might compute D Beta L for a given layer, and then update the parameters Beta, gets updated as Beta minus learning rate times D Beta L. And you can also use Adam or RMSprop or momentum in order to update the parameters Beta and Gamma, not just gradient descent. And even though in the previous video, I had explained what the Batch Norm operation does, computes mean and variances and subtracts and divides by them. If they are using a Deep Learning Programming Framework, usually you won't have to implement the Batch Norm step on Batch Norm layer yourself. So the probing frameworks, that can be sub one line of code. So for example, in terms of flow framework, you can implement Batch Normalization with this function. We'll talk more about probing frameworks later, but in practice you might not end up needing to implement all these details yourself, knowing how it works so that you can get a better understanding of what your code is doing. But implementing Batch Norm is often one line of code in the deep learning frameworks. Now, so far, we've talked about Batch Norm as if you were training on your entire training site at the time as if you are using Batch gradient descent. In practice, Batch Norm is usually applied with mini-batches of your training set. So the way you actually apply Batch Norm is you take your first mini-batch and compute Z1. Same as we did on the previous slide using the parameters W1, B1 and then you take just this mini-batch and computer mean and variance of the Z1 on just this mini batch and then Batch Norm would subtract by the mean and divide by the standard deviation and then re-scale by Beta 1, Gamma 1, to give you Z1, and all this is on the first mini-batch, then you apply the activation function to get A1, and then you compute Z2 using W2, B2, and so on. So you do all this in order to perform one step of gradient descent on the first mini-batch and then goes to the second mini-batch X2, and you do something similar where you will now compute Z1 on the second mini-batch and then use Batch Norm to compute Z1 tilde. And so here in this Batch Norm step, You would be normalizing Z tilde using just the data in your second mini-batch, so does Batch Norm step here. Let's look at the examples in your second mini-batch, computing the mean and variances of the Z1's on just that mini-batch and re-scaling by Beta and Gamma to get Z tilde, and so on. And you do this with a third mini-batch, and keep training. Now, there's one detail to the parameterization that I want to clean up, which is previously, I said that the parameters was WL, BL, for each layer as well as Beta L, and Gamma L. Now notice that the way Z was computed is as follows, ZL = WL x A of L - 1 + B of L. But what Batch Norm does, is it is going to look at the mini-batch and normalize ZL to first of mean 0 and standard variance, and then a rescale by Beta and Gamma. But what that means is that, whatever is the value of BL is actually going to just get subtracted out, because during that Batch Normalization step, you are going to compute the means of the ZL's and subtract the mean. And so adding any constant to all of the examples in the mini-batch, it doesn't change anything. Because any constant you add will get cancelled out by the mean subtractions step. So, if you're using Batch Norm, you can actually eliminate that parameter, or if you want, think of it as setting it permanently to 0. So then the parameterization becomes ZL is just WL x AL - 1, And then you compute ZL normalized, and we compute Z tilde = Gamma ZL + Beta, you end up using this parameter Beta L in order to decide whats that mean of Z tilde L. Which is why guess post in this layer. So just to recap, because Batch Norm zeroes out the mean of these ZL values in the layer, there's no point having this parameter BL, and so you must get rid of it, and instead is sort of replaced by Beta L, which is a parameter that controls that ends up affecting the shift or the biased terms. Finally, remember that the dimension of ZL, because if you're doing this on one example, it's going to be NL by 1, and so BL, a dimension, NL by one, if NL was the number of hidden units in layer L. And so the dimension of Beta L and Gamma L is also going to be NL by 1 because that's the number of hidden units you have. You have NL hidden units, and so Beta L and Gamma L are used to scale the mean and variance of each of the hidden units to whatever the network wants to set them to. So, let's pull all together and describe how you can implement gradient descent using Batch Norm. Assuming you're using mini-batch gradient descent, it rates for T = 1 to the number of mini batches. You would implement forward prop on mini-batch XT and doing forward prop in each hidden layer, use Batch Norm to replace ZL with Z tilde L. And so then it shows that within that mini-batch, the value Z end up with some normalized mean and variance and the values and the version of the normalized mean that and variance is Z tilde L. And then, you use back prop to compute DW, DB, for all the values of L, D Beta, D Gamma. Although, technically, since you have got to get rid of B, this actually now goes away. And then finally, you update the parameters. So, W gets updated as W minus the learning rate times, as usual, Beta gets updated as Beta minus learning rate times DB, and similarly for Gamma. And if you have computed the gradient as follows, you could use gradient descent. That's what I've written down here, but this also works with gradient descent with momentum, or RMSprop, or Adam. Where instead of taking this gradient descent update,nini-batch you could use the updates given by these other algorithms as we discussed in the previous week's videos. Some of these other optimization algorithms as well can be used to update the parameters Beta and Gamma that Batch Norm added to algorithm. So, I hope that gives you a sense of how you could implement Batch Norm from scratch if you wanted to. If you're using one of the Deep Learning Programming frameworks which we will talk more about later, hopefully you can just call someone else's implementation in the Programming framework which will make using Batch Norm much easier. Now, in case Batch Norm still seems a little bit mysterious if you're still not quite sure why it speeds up training so dramatically, let's go to the next video and talk more about why Batch Norm really works and what it is really doing.\n\nWhy does Batch Norm work?\nSo, why does batch norm work? Here's one reason, you've seen how normalizing the input features, the X's, to mean zero and variance one, how that can speed up learning. So rather than having some features that range from zero to one, and some from one to a 1,000, by normalizing all the features, input features X, to take on a similar range of values that can speed up learning. So, one intuition behind why batch norm works is, this is doing a similar thing, but further values in your hidden units and not just for your input there. Now, this is just a partial picture for what batch norm is doing. There are a couple of further intuitions, that will help you gain a deeper understanding of what batch norm is doing. Let's take a look at those in this video. A second reason why batch norm works, is it makes weights, later or deeper than your network, say the weight on layer 10, more robust to changes to weights in earlier layers of the neural network, say, in layer one. To explain what I mean, let's look at this most vivid example. Let's see a training on network, maybe a shallow network, like logistic regression or maybe a neural network, maybe a shallow network like this regression or maybe a deep network, on our famous cat detection toss. But let's say that you've trained your data sets on all images of black cats. If you now try to apply this network to data with colored cats where the positive examples are not just black cats like on the left, but to color cats like on the right, then your cosfa might not do very well. So in pictures, if your training set looks like this, where you have positive examples here and negative examples here, but you were to try to generalize it, to a data set where maybe positive examples are here and the negative examples are here, then you might not expect a module trained on the data on the left to do very well on the data on the right. Even though there might be the same function that actually works well, but you wouldn't expect your learning algorithm to discover that green decision boundary, just looking at the data on the left. So, this idea of your data distribution changing goes by the somewhat fancy name, covariate shift. And the idea is that, if you've learned some X to Y mapping, if the distribution of X changes, then you might need to retrain your learning algorithm. And this is true even if the function, the ground true function, mapping from X to Y, remains unchanged, which it is in this example, because the ground true function is, is this picture a cat or not. And the need to retain your function becomes even more acute or it becomes even worse if the ground true function shifts as well. So, how does this problem of covariate shift apply to a neural network? Consider a deep network like this, and let's look at the learning process from the perspective of this certain layer, the third hidden layer. So this network has learned the parameters W3 and B3. And from the perspective of the third hidden layer, it gets some set of values from the earlier layers, and then it has to do some stuff to hopefully make the output Y-hat close to the ground true value Y. So let me cover up the nose on the left for a second. So from the perspective of this third hidden layer, it gets some values, let's call them A_2_1, A_2_2, A_2_3, and A_2_4. But these values might as well be features X1, X2, X3, X4, and the job of the third hidden layer is to take these values and find a way to map them to Y-hat. So you can imagine doing great intercepts, so that these parameters W_3_B_3 as well as maybe W_4_B_4, and even W_5_B_5, maybe try and learn those parameters, so the network does a good job, mapping from the values I drew in black on the left to the output values Y-hat. But now let's uncover the left of the network again. The network is also adapting parameters W_2_B_2 and W_1B_1, and so as these parameters change, these values, A_2, will also change. So from the perspective of the third hidden layer, these hidden unit values are changing all the time, and so it's suffering from the problem of covariate shift that we talked about on the previous slide. So what batch norm does, is it reduces the amount that the distribution of these hidden unit values shifts around. And if it were to plot the distribution of these hidden unit values, maybe this is technically renormalizer Z, so this is actually Z_2_1 and Z_2_2, and I also plot two values instead of four values, so we can visualize in 2D. What batch norm is saying is that, the values for Z_2_1 Z and Z_2_2 can change, and indeed they will change when the neural network updates the parameters in the earlier layers. But what batch norm ensures is that no matter how it changes, the mean and variance of Z_2_1 and Z_2_2 will remain the same. So even if the exact values of Z_2_1 and Z_2_2 change, their mean and variance will at least stay same mean zero and variance one. Or, not necessarily mean zero and variance one, but whatever value is governed by beta two and gamma two. Which, if the neural networks chooses, can force it to be mean zero and variance one. Or, really, any other mean and variance. But what this does is, it limits the amount to which updating the parameters in the earlier layers can affect the distribution of values that the third layer now sees and therefore has to learn on. And so, batch norm reduces the problem of the input values changing, it really causes these values to become more stable, so that the later layers of the neural network has more firm ground to stand on. And even though the input distribution changes a bit, it changes less, and what this does is, even as the earlier layers keep learning, the amounts that this forces the later layers to adapt to as early as layer changes is reduced or, if you will, it weakens the coupling between what the early layers parameters has to do and what the later layers parameters have to do. And so it allows each layer of the network to learn by itself, a little bit more independently of other layers, and this has the effect of speeding up of learning in the whole network. So I hope this gives some better intuition, but the takeaway is that batch norm means that, especially from the perspective of one of the later layers of the neural network, the earlier layers don't get to shift around as much, because they're constrained to have the same mean and variance. And so this makes the job of learning on the later layers easier. It turns out batch norm has a second effect, it has a slight regularization effect. So one non-intuitive thing of a batch norm is that each mini-batch, I will say mini-batch X_t, has the values Z_t, has the values Z_l, scaled by the mean and variance computed on just that one mini-batch. Now, because the mean and variance computed on just that mini-batch as opposed to computed on the entire data set, that mean and variance has a little bit of noise in it, because it's computed just on your mini-batch of, say, 64, or 128, or maybe 256 or larger training examples. So because the mean and variance is a little bit noisy because it's estimated with just a relatively small sample of data, the scaling process, going from Z_l to Z_2_l, that process is a little bit noisy as well, because it's computed, using a slightly noisy mean and variance. So similar to dropout, it adds some noise to each hidden layer's activations. The way dropout has noises, it takes a hidden unit and it multiplies it by zero with some probability. And multiplies it by one with some probability. And so your dropout has multiple of noise because it's multiplied by zero or one, whereas batch norm has multiples of noise because of scaling by the standard deviation, as well as additive noise because it's subtracting the mean. Well, here the estimates of the mean and the standard deviation are noisy. And so, similar to dropout, batch norm therefore has a slight regularization effect. Because by adding noise to the hidden units, it's forcing the downstream hidden units not to rely too much on any one hidden unit. And so similar to dropout, it adds noise to the hidden layers and therefore has a very slight regularization effect. Because the noise added is quite small, this is not a huge regularization effect, and you might choose to use batch norm together with dropout, and you might use batch norm together with dropouts if you want the more powerful regularization effect of dropout. And maybe one other slightly non-intuitive effect is that, if you use a bigger mini-batch size, right, so if you use use a mini-batch size of, say, 512 instead of 64, by using a larger mini-batch size, you're reducing this noise and therefore also reducing this regularization effect. So that's one strange property of dropout which is that by using a bigger mini-batch size, you reduce the regularization effect. Having said this, I wouldn't really use batch norm as a regularizer, that's really not the intent of batch norm, but sometimes it has this extra intended or unintended effect on your learning algorithm. But, really, don't turn to batch norm as a regularization. Use it as a way to normalize your hidden units activations and therefore speed up learning. And I think the regularization is an almost unintended side effect. So I hope that gives you better intuition about what batch norm is doing. Before we wrap up the discussion on batch norm, there's one more detail I want to make sure you know, which is that batch norm handles data one mini-batch at a time. It computes mean and variances on mini-batches. So at test time, you try and make predictors, try and evaluate the neural network, you might not have a mini-batch of examples, you might be processing one single example at the time. So, at test time you need to do something slightly differently to make sure your predictions make sense. Like in the next and final video on batch norm, let's talk over the details of what you need to do in order to take your neural network trained using batch norm to make predictions.\n\nBatch Norm at Test Time\nBatch norm processes your data one mini batch at a time, but the test time you might need to process the examples one at a time. Let's see how you can adapt your network to do that. Recall that during training, here are the equations you'd use to implement batch norm. Within a single mini batch, you'd sum over that mini batch of the ZI values to compute the mean. So here, you're just summing over the examples in one mini batch. I'm using M to denote the number of examples in the mini batch not in the whole training set. Then, you compute the variance and then you compute Z norm by scaling by the mean and standard deviation with Epsilon added for numerical stability. And then Z\u0303 is taking Z norm and rescaling by gamma and beta. So, notice that mu and sigma squared which you need for this scaling calculation are computed on the entire mini batch. But the test time you might not have a mini batch of 6428 or 2056 examples to process at the same time. So, you need some different way of coming up with mu and sigma squared. And if you have just one example, taking the mean and variance of that one example, doesn't make sense. So what's actually done? In order to apply your neural network and test time is to come up with some separate estimate of mu and sigma squared. And in typical implementations of batch norm, what you do is estimate this using a exponentially weighted average where the average is across the mini batches. So, to be very concrete here's what I mean. Let's pick some layer L and let's say you're going through mini batches X1, X2 together with the corresponding values of Y and so on. So, when training on X1 for that layer L, you get some mu L. And in fact, I'm going to write this as mu for the first mini batch and that layer. And then when you train on the second mini batch for that layer and that mini batch,you end up with some second value of mu. And then for the fourth mini batch in this hidden layer, you end up with some third value for mu. So just as we saw how to use a exponentially weighted average to compute the mean of Theta one, Theta two, Theta three when you were trying to compute a exponentially weighted average of the current temperature, you would do that to keep track of what's the latest average value of this mean vector you've seen. So that exponentially weighted average becomes your estimate for what the mean of the Zs is for that hidden layer and similarly, you use an exponentially weighted average to keep track of these values of sigma squared that you see on the first mini batch in that layer, sigma square that you see on second mini batch and so on. So you keep a running average of the mu and the sigma squared that you're seeing for each layer as you train the neural network across different mini batches. Then finally at test time, what you do is in place of this equation, you would just compute Z norm using whatever value your Z have, and using your exponentially weighted average of the mu and sigma square whatever was the latest value you have to do the scaling here. And then you would compute Z\u0303 on your one test example using that Z norm that we just computed on the left and using the beta and gamma parameters that you have learned during your neural network training process. So the takeaway from this is that during training time mu and sigma squared are computed on an entire mini batch of say 64 engine, 28 or some number of examples. But that test time, you might need to process a single example at a time. So, the way to do that is to estimate mu and sigma squared from your training set and there are many ways to do that. You could in theory run your whole training set through your final network to get mu and sigma squared. But in practice, what people usually do is implement and exponentially weighted average where you just keep track of the mu and sigma squared values you're seeing during training and use and exponentially the weighted average, also sometimes called the running average, to just get a rough estimate of mu and sigma squared and then you use those values of mu and sigma squared that test time to do the scale and you need the head and unit values Z. In practice, this process is pretty robust to the exact way you used to estimate mu and sigma squared. So, I wouldn't worry too much about exactly how you do this and if you're using a deep learning framework, they'll usually have some default way to estimate the mu and sigma squared that should work reasonably well as well. But in practice, any reasonable way to estimate the mean and variance of your head and unit values Z should work fine at test. So, that's it for batch norm and using it. I think you'll be able to train much deeper networks and get your learning algorithm to run much more quickly. Before we wrap up for this week, I want to share with you some thoughts on deep learning frameworks as well. Let's start to talk about that in the next video.\n\nSoftmax Regression\nSo far, the classification examples we've talked about have used binary classification, where you had two possible labels, 0 or 1. Is it a cat, is it not a cat? What if we have multiple possible classes? There's a generalization of logistic regression called Softmax regression. The less you make predictions where you're trying to recognize one of C or one of multiple classes, rather than just recognize two classes. Let's take a look. Let's say that instead of just recognizing cats you want to recognize cats, dogs, and baby chicks. So I'm going to call cats class 1, dogs class 2, baby chicks class 3. And if none of the above, then there's an other or a none of the above class, which I'm going to call class 0. So here's an example of the images and the classes they belong to. That's a picture of a baby chick, so the class is 3. Cats is class 1, dog is class 2, I guess that's a koala, so that's none of the above, so that is class 0, class 3 and so on. So the notation we're going to use is, I'm going to use capital C to denote the number of classes you're trying to categorize your inputs into. And in this case, you have four possible classes, including the other or the none of the above class. So when you have four classes, the numbers indexing your classes would be 0 through capital C minus one. So in other words, that would be zero, one, two or three. In this case, we're going to build a new XY, where the upper layer has four, or in this case the variable capital alphabet C upward units.\nSo N, the number of units upper layer which is layer L is going to equal to 4 or in general this is going to equal to C. And what we want is for the number of units in the upper layer to tell us what is the probability of each of these four classes. So the first node here is supposed to output, or we want it to output the probability that is the other class, given the input x, this will output probability there's a cat. Give an x, this will output probability as a dog. Give an x, that will output the probability. I'm just going to abbreviate baby chick to baby C, given the input x.\nSo here, the output labels y hat is going to be a four by one dimensional vector, because it now has to output four numbers, giving you these four probabilities.\nAnd because probabilities should sum to one, the four numbers in the output y hat, they should sum to one.\nThe standard model for getting your network to do this uses what's called a Softmax layer, and the output layer in order to generate these outputs. Then write down the map, then you can come back and get some intuition about what the Softmax there is doing.\nSo in the final layer of the neural network, you are going to compute as usual the linear part of the layers. So z, capital L, that's the z variable for the final layer. So remember this is layer capital L. So as usual you compute that as wL times the activation of the previous layer plus the biases for that final layer. Now having computer z, you now need to apply what's called the Softmax activation function.\nSo that activation function is a bit unusual for the Softmax layer, but this is what it does.\nFirst, we're going to computes a temporary variable, which we're going to call t, which is e to the z L. So this is a part element-wise. So zL here, in our example, zL is going to be four by one. This is a four dimensional vector. So t Itself e to the zL, that's an element wise exponentiation. T will also be a 4.1 dimensional vector. Then the output aL, is going to be basically the vector t will normalized to sum to 1. So aL is going to be e to the zL divided by sum from J equal 1 through 4, because we have four classes of t substitute i. So in other words we're saying that aL is also a four by one vector, and the i element of this four dimensional vector. Let's write that, aL substitute i that's going to be equal to ti over sum of ti, okay? In case this math isn't clear, we'll do an example in a minute that will make this clearer. So in case this math isn't clear, let's go through a specific example that will make this clearer. Let's say that your computer zL, and zL is a four dimensional vector, let's say is 5, 2, -1, 3. What we're going to do is use this element-wise exponentiation to compute this vector t. So t is going to be e to the 5, e to the 2, e to the -1, e to the 3. And if you plug that in the calculator, these are the values you get. E to the 5 is 1484, e squared is about 7.4, e to the -1 is 0.4, and e cubed is 20.1. And so, the way we go from the vector t to the vector aL is just to normalize these entries to sum to one. So if you sum up the elements of t, if you just add up those 4 numbers you get 176.3. So finally, aL is just going to be this vector t, as a vector, divided by 176.3. So for example, this first node here, this will output e to the 5 divided by 176.3. And that turns out to be 0.842. So saying that, for this image, if this is the value of z you get, the chance of it being called zero is 84.2%. And then the next nodes outputs e squared over 176.3, that turns out to be 0.042, so this is 4.2% chance. The next one is e to -1 over that, which is 0.042. And the final one is e cubed over that, which is 0.114. So it is 11.4% chance that this is class number three, which is the baby C class, right? So there's a chance of it being class zero, class one, class two, class three. So the output of the neural network aL, this is also y hat. This is a 4 by 1 vector where the elements of this 4 by 1 vector are going to be these four numbers. Then we just compute it. So this algorithm takes the vector zL and is four probabilities that sum to 1. And if we summarize what we just did to math from zL to aL, this whole computation confusing exponentiation to get this temporary variable t and then normalizing, we can summarize this into a Softmax activation function and say aL equals the activation function g applied to the vector zL. The unusual thing about this particular activation function is that, this activation function g, it takes a input a 4 by 1 vector and it outputs a 4 by 1 vector. So previously, our activation functions used to take in a single row value input. So for example, the sigmoid and the value activation functions input the real number and output a real number. The unusual thing about the Softmax activation function is, because it needs to normalized across the different possible outputs, and needs to take a vector and puts in outputs of vector. So one of the things that a Softmax cross layer can represent, I'm going to show you some examples where you have inputs x1, x2. And these feed directly to a Softmax layer that has three or four, or more output nodes that then output y hat. So I'm going to show you a new network with no hidden layer, and all it does is compute z1 equals w1 times the input x plus b. And then the output a1, or y hat is just the Softmax activation function applied to z1. So in this neural network with no hidden layers, it should give you a sense of the types of things a Softmax function can represent. So here's one example with just raw inputs x1 and x2. A Softmax layer with C equals 3 upper classes can represent this type of decision boundaries. Notice this kind of several linear decision boundaries, but this allows it to separate out the data into three classes. And in this diagram, what we did was we actually took the training set that's kind of shown in this figure and train the Softmax cross fire with the upper labels on the data. And then the color on this plot shows fresh holding the upward of the Softmax cross fire, and coloring in the input base on which one of the three outputs have the highest probability. So we can maybe we kind of see that this is like a generalization of logistic regression with sort of linear decision boundaries, but with more than two classes [INAUDIBLE] class 0, 1, the class could be 0, 1, or 2. Here's another example of the decision boundary that a Softmax cross fire represents when three normal datasets with three classes. And here's another one, rIght, so this is a, but one intuition is that the decision boundary between any two classes will be more linear. That's why you see for example that decision boundary between the yellow and the various classes, that's the linear boundary where the purple and red linear in boundary between the purple and yellow and other linear decision boundary. But able to use these different linear functions in order to separate the space into three classes. Let's look at some examples with more classes. So it's an example with C equals 4, so that the green class and Softmax can continue to represent these types of linear decision boundaries between multiple classes. So here's one more example with C equals 5 classes, and here's one last example with C equals 6. So this shows the type of things the Softmax crossfire can do when there is no hidden layer of class, even much deeper neural network with x and then some hidden units, and then more hidden units, and so on. Then you can learn even more complex non-linear decision boundaries to separate out multiple different classes.\nSo I hope this gives you a sense of what a Softmax layer or the Softmax activation function in the neural network can do. In the next video, let's take a look at how you can train a neural network that uses a Softmax layer.\n\nTraining a Softmax Classifier\nIn the last video, you learned about the soft master, the softmax activation function. In this video, you deepen your understanding of softmax classification, and also learn how the training model that uses a softmax layer. Recall our earlier example where the output layer computes z[L] as follows. So we have four classes, c = 4 then z[L] can be (4,1) dimensional vector and we said we compute t which is this temporary variable that performs element y's exponentiation. And then finally, if the activation function for your output layer, g[L] is the softmax activation function, then your outputs will be this. It's basically taking the temporarily variable t and normalizing it to sum to 1. So this then becomes a(L). So you notice that in the z vector, the biggest element was 5, and the biggest probability ends up being this first probability. The name softmax comes from contrasting it to what's called a hard max which would have taken the vector Z and matched it to this vector. So hard max function will look at the elements of Z and just put a 1 in the position of the biggest element of Z and then 0s everywhere else. And so this is a very hard max where the biggest element gets a output of 1 and everything else gets an output of 0. Whereas in contrast, a softmax is a more gentle mapping from Z to these probabilities. So, I'm not sure if this is a great name but at least, that was the intuition behind why we call it a softmax, all this in contrast to the hard max.\nAnd one thing I didn't really show but had alluded to is that softmax regression or the softmax identification function generalizes the logistic activation function to C classes rather than just two classes. And it turns out that if C = 2, then softmax with C = 2 essentially reduces to logistic regression. And I'm not going to prove this in this video but the rough outline for the proof is that if C = 2 and if you apply softmax, then the output layer, a[L], will output two numbers if C = 2, so maybe it outputs 0.842 and 0.158, right? And these two numbers always have to sum to 1. And because these two numbers always have to sum to 1, they're actually redundant. And maybe you don't need to bother to compute two of them, maybe you just need to compute one of them. And it turns out that the way you end up computing that number reduces to the way that logistic regression is computing its single output. So that wasn't much of a proof but the takeaway from this is that softmax regression is a generalization of logistic regression to more than two classes. Now let's look at how you would actually train a neural network with a softmax output layer. So in particular, let's define the loss functions you use to train your neural network. Let's take an example. Let's see of an example in your training set where the target output, the ground true label is 0 1 0 0. So the example from the previous video, this means that this is an image of a cat because it falls into Class 1. And now let's say that your neural network is currently outputting y hat equals, so y hat would be a vector probability is equal to sum to 1. 0.1, 0.4, so you can check that sums to 1, and this is going to be a[L]. So the neural network's not doing very well in this example because this is actually a cat and assigned only a 20% chance that this is a cat. So didn't do very well in this example.\nSo what's the last function you would want to use to train this neural network? In softmax classification, they'll ask me to produce this negative sum of j=1 through 4. And it's really sum from 1 to C in the general case. We're going to just use 4 here, of yj log y hat of j. So let's look at our single example above to better understand what happens. Notice that in this example, y1 = y3 = y4 = 0 because those are 0s and only y2 = 1. So if you look at this summation, all of the terms with 0 values of yj were equal to 0. And the only term you're left with is -y2 log y hat 2, because we use sum over the indices of j, all the terms will end up 0, except when j is equal to 2. And because y2 = 1, this is just -log y hat 2. So what this means is that, if your learning algorithm is trying to make this small because you use gradient descent to try to reduce the loss on your training set. Then the only way to make this small is to make this small. And the only way to do that is to make y hat 2 as big as possible.\nAnd these are probabilities, so they can never be bigger than 1. But this kind of makes sense because x for this example is the picture of a cat, then you want that output probability to be as big as possible. So more generally, what this loss function does is it looks at whatever is the ground true class in your training set, and it tries to make the corresponding probability of that class as high as possible. If you're familiar with maximum likelihood estimation statistics, this turns out to be a form of maximum likelyhood estimation. But if you don't know what that means, don't worry about it. The intuition we just talked about will suffice.\nNow this is the loss on a single training example. How about the cost J on the entire training set. So, the class of setting of the parameters and so on, of all the ways and biases, you define that as pretty much what you'd guess, sum of your entire training sets are the loss, your learning algorithms predictions are summed over your training samples. And so, what you do is use gradient descent in order to try to minimize this class. Finally, one more implementation detail. Notice that because C is equal to 4, y is a 4 by 1 vector, and y hat is also a 4 by 1 vector. So if you're using a vectorized limitation, the matrix capital Y is going to be y(1), y(2), through y(m), stacked horizontally. And so for example, if this example up here is your first training example then the first column of this matrix Y will be 0 1 0 0 and then maybe the second example is a dog, maybe the third example is a none of the above, and so on. And then this matrix Y will end up being a 4 by m dimensional matrix. And similarly, Y hat will be y hat 1 stacked up horizontally going through y hat m, so this is actually y hat 1.\nAll the output on the first training example then y hat will these 0.3, 0.2, 0.1, and 0.4, and so on. And y hat itself will also be 4 by m dimensional matrix. Finally, let's take a look at how you'd implement gradient descent when you have a softmax output layer. So this output layer will compute z[L] which is C by 1 in our example, 4 by 1 and then you apply the softmax attribution function to get a[L], or y hat.\nAnd then that in turn allows you to compute the loss. So with talks about how to implement the forward propagation step of a neural network to get these outputs and to compute that loss. How about the back propagation step, or gradient descent? Turns out that the key step or the key equation you need to initialize back prop is this expression, that the derivative with respect to z at the loss layer, this turns out, you can compute this y hat, the 4 by 1 vector, minus y, the 4 by 1 vector. So you notice that all of these are going to be 4 by 1 vectors when you have 4 classes and C by 1 in the more general case.\nAnd so this going by our usual definition of what is dz, this is the partial derivative of the class function with respect to z[L]. If you are an expert in calculus, you can derive this yourself. Or if you're an expert in calculus, you can try to derive this yourself, but using this formula will also just work fine, if you have a need to implement this from scratch. With this, you can then compute dz[L] and then sort of start off the back prop process to compute all the derivatives you need throughout your neural network. But it turns out that in this week's primary exercise, we'll start to use one of the deep learning program frameworks and for those primary frameworks, usually it turns out you just need to focus on getting the forward prop right. And so long as you specify it as a primary framework, the forward prop pass, the primary framework will figure out how to do back prop, how to do the backward pass for you.\nSo this expression is worth keeping in mind for if you ever need to implement softmax regression, or softmax classification from scratch. Although you won't actually need this in this week's primary exercise because the primary framework you use will take care of this derivative computation for you. So that's it for softmax classification, with it you can now implement learning algorithms to characterized inputs into not just one of two classes, but one of C different classes. Next, I want to show you some of the deep learning programming frameworks which can make you much more efficient in terms of implementing deep learning algorithms. Let's go on to the next video to discuss that.\n", "source": "coursera_b", "evaluation": "exam"}
{"instructions": ["Question 1. Which of the following factors are important when choosing an advertising method? Select all that apply.\nA. Target audience\nB. Budget\nC. Location\nD. Time period", "Question 2. Which of the following questions are examples of leading questions? Select all that apply.\nA. This product is too expensive, isn't it?\nB. Do you prefer chocolate or vanilla?\nC. Why did a recent video go viral?\nD. What are the top five features you would like to see in a car package?", "Question 3. In the context of data analytics, what is the purpose of asking action-oriented questions? Select all that apply.\nA. Encourage change\nB. Generate insights\nC. Help solve problems\nD. Identify patterns", "Question 4. Which of the following questions are examples of closed-ended questions? Select all that apply.\nA. Were you satisfied with the customer trial?\nB. What did you learn about customer experience from the trial?\nC. Is the new tool faster, slower, or about the same as the old tool?\nD. What price range would make you consider purchasing this product?", "Question 5. In data analytics, how are dashboards different from reports?\nA. Dashboards contain static data. Reports contain data that is constantly changing.\nB. Dashboards are used to share updates with stakeholders only periodically. Reports give stakeholders continuous access to data.\nC. Dashboards provide a high level look at historical data. Reports provide a more detailed look at live, interactive data.\nD. Dashboards monitor live, incoming data from multiple datasets and organize the information into one central location. Reports are static collections of data.", "Question 6. Small data differs from big data in what ways? Select all that apply.\nA. Small data focuses on short, well-defined time periods. Big data focuses on change over a long period of time.\nB. Small data is typically stored in a database. Big data is typically stored in a spreadsheet.\nC. Small data is effective for analyzing day-to-day decisions. Big data is effective for analyzing more substantial decisions.\nD. Small data involves datasets concerned with a small number of specific metrics. Big data involves datasets that are larger and less specific.", "Question 7. What is the main purpose of asking time-bound questions in data analysis? Select all that apply.\nA. Limit the range of analysis possibilities\nB. Focus on relevant data\nC. Identify trends\nD. Analyze historical data", "Question 8. Asking questions including, \u201cDoes my analysis answer the original question?\u201d and \u201cAre there other angles I haven\u2019t considered?\u201d enable data analysts to accomplish what tasks? Select all that apply.\nA. Identify primary and secondary stakeholders\nB. Use data to get to a solid conclusion\nC. Help team members make informed, data-driven decisions\nD. Consider the best ways to share data with others", "Question 9. Which of the following questions are examples of vague questions? Select all that apply.\nA. Does the tool work for you?\nB. What environmental factors changed between 1983 and 2004 that could cause Pine Barrens tree frogs to disappear from the Sandhills Regions?\nC. How important is your car having four-wheel drive?\nD. How can we get customers to recycle our product packaging?", "Question 10. What is the main purpose of asking relevant questions in data analysis? Select all that apply.\nA. Address the problem being investigated\nB. Generate useful insights\nC. Encourage change\nD. Identify patterns and save your time"], "outputs": ["ABCD", "AB", "ABC", "AC", "D", "ACD", "AB", "BCD", "ACD", "AB"], "input": "Introduction to problem-solving and effective questioning \nWelcome to the second course in the Google Data Analytics certificate. If you completed Course One, we met briefly at the beginning, but for those of you who are just joining us, my name is Ximena, and I'm a Google Finance data analyst. I think it's really wonderful that you're here with me learning about the fascinating field of data analytics. Learning and education have always been very important to me. When I was young, my mom always said, \"I can't leave you an inheritance, but I can give you an education that opens doors.\" That always pushed me to keep learning, and that education gave me the confidence to apply for my job at Google. Now I get to do really meaningful work every day. Just recently I worked as an analyst on a team called Verily Life Sciences. We were helping to get life-saving medical supplies to those who need it most. To do this, we forecasted what health care professionals would need on hand and then shared that information with networks. The information that my team provided helped make data driven decisions that actually saved lives. I'm thrilled to be your instructor for this course. We're going to talk about the difference between effective and ineffective questions and learn how to ask great questions that lead to insights that can help you solve business problems. You will discover that effective questions help you to make the most of all the data analysis phases. You may remember that these phases include ask, prepare, process, analyze, share, and act. In the ask step, we define the problem we're solving and make sure that we fully understand stakeholder expectations. This will help keep you focused on the actual problem, which leads to more successful outcomes. So we'll begin this course by talking about problem solving and some of the common types of business problems that data analysts help solve. And because this course focuses on the ask phase, you'll learn how to craft effective questions that help you collect the right data to solve those problems. Next, we'll talk about the many different types of data. You'll learn how and when each is the most useful. You'll also get a chance to explore spreadsheets further and discover how they can help make your data analysis even more effective. And then we'll start learning about structured thinking. Structured thinking is the process of recognizing the current problem or situation, organizing available information, revealing gaps and opportunities, and identifying the options. In this process, you address a vague, complex problem by breaking it down into smaller steps, and then those steps lead you to a logical solution. We'll work together to be sure you fully understand how to use structured thinking and data analysis. Finally, we'll learn some proven strategies for communicating with others effectively. I can't wait to share more about my passion for data analytics with you, so let's get started.\n\nData in action\nIn this video, I'm going to share an interesting data analytics case study, it will illustrate how problem solving relates to each phase of the data analysis process and shed some light on how these phases work in the real world. It's about a small business that used data to solve a unique problem it was facing. The business is called Anywhere Gaming Repair. It's a service provider that comes to you to fix your broken video game systems or accessories. The owner wanted to expand his business. He knew advertising is a proven way to get more customers, but he wasn't sure where to start. There are all kinds of different advertising strategies, including print, billboards, TV commercials, public transportation, podcasts, and radio. One of the key things to think about when choosing an advertising method is your target audience, in other words, the specific people you're trying to reach. For example, if a medical equipment manufacturer wanted to reach doctors, placing an ad in a health magazine would be a smart choice. Or if a catering company wanted to find new cooks, it might advertise using a poster at a bus stop near a cooking school. Both of these are great ways to get your ad seen by your target audience. The second thing to think about is your budget and how much the different advertising methods will cost. For instance, a TV ad is likely to be more expensive than a radio ad. A large billboard will probably cost more than a small poster on the back of a city bus. The business owner asked a data analyst, Maria, to make a recommendation. She started with the first step in the data analysis process, Ask. Maria began by defining the problem that needed to be solved. To do this, she first had to zoom out and look at the whole situation in context. That way she could be sure that she was focusing on the real problem and not just its symptoms. This leads us to another important part of the problem solving process, collaborating with stakeholders and understanding their needs. For Anywhere Gaming Repair, stakeholders included the owner, the vice president of communications, and the director of marketing and finance. Working together, Maria and the stakeholders agreed on the problem, not knowing their target audience's preferred type of advertising. Next step was the prepare phase, where Maria collected data for the upcoming analysis process. But first, she needed to better understand the company's target audience, people with video game systems. After that, Maria collected data on the different advertising methods. This way, she would be able to determine which was the most popular one with the company's target audience. Then she moved on to the process step. Here Maria cleaned the data to eliminate any errors or inaccuracies that could get in the way of the result. As we've learned, when you clean data, you transform it into a more useful format, create more complete information and remove outliers. Then it was time to analyze. In this step, Maria wanted to find out two things. First, who's most likely to own a video gaming system? Second, where are these people most likely to see an advertisement? Maria, first discovered that people between the ages of 18 and 34 are most likely to make video game related purchases. She could confirm that Anywhere Gaming Repair's target audience was people 18-34 years old. This was who they should be trying to reach. With this in mind, Maria then learned that both TV commercials and podcasts are very popular with people in the target audience. Because Maria knew Anywhere Gaming Repair had a limited budget and understanding the high cost of TV commercials, her recommendation was to advertise in podcasts because they are more cost-effective. Now that she had her analysis, it was time for Maria to share her recommendation so the company could make a data driven decision. She summarized her results using clear and compelling visuals of the analysis. This helped her stakeholders understand the solution to the original problem. Finally, Anywhere Gaming Repair took action, they worked with a local podcast production agency to create a 30 second ad about their services. The ad ran on podcast for a month, and it worked. They saw an increase in customers after just the first week. By the end of week 4, they had 85 new customers. There you go. Effective problem solving using data analysis phases in action. Now, you've seen how the six phases of data analysis can be applied to problem solving and how you can use that to solve real world problems.\n\nNikki: The data process works\nI'm Nikki and I manage the education, evaluation, assessment, and research team. My favorite part of the data analysis process is finding the hardest problem and asking a million questions about it and seeing if it's even possible to get an answer. One of the problems that we've tackled here at Google is our Noogler onboarding program, which is how we onboard new hires. One of the things that we've done is ask the question, how do we know whether or not Nooglers are onboarding faster through our new onboarding program than our old onboarding program where we used to lecture them. We worked really closely with the content providers to understand just exactly what does it mean to onboard someone faster? Once we asked all the questions, what we did is we prepared the data by understanding who was the population of the new hires that we were examining. We prepared our data by going through and understanding who our populations were, by understanding who our sample set was, who our control group was, who our experiment group was, where were our data sources, and make sure that it was in a set, in a format that was clean and digestible for us to write the proper scripts for. So the next step for us was to process the data to make sure that it was in a format that we could actually analyze in SQL, making sure that was in the right format, in the right columns, and in the right tables for us. To analyze the data, we wrote scripts in SQL and in R to correlate the data to the control group or the experiment group and interpret the data to understand, were there any changes in the behavioral indicators that we saw? Once we analyze all the data, we want to report on it in a way that our stakeholders could understand. Depending on who our stakeholders were, we prepared reports, dashboards and presentations, and shared that information out. Once all of our reports were complete, we saw really positive results and decided to act on it by continuing our project-based learning onboarding program. It was really satisfying to know that we have the data to support it and that it really, really worked. And not just that the data was there, but that we knew that our students were learning and that they were more productive, faster back on their jobs.\n\nCommon problem types\nIn a previous video, I shared how data analysis helped a company figure out where to advertise its services. An important part of this process was strong problem-solving skills. As a data analyst, you'll find that problems are at the center of what you do every single day, but that's a good thing. Think of problems as opportunities to put your skills to work and find creative and insightful solutions. Problems can be small or large, simple or complex, no problem is like another and they all require a slightly different approach but the first step is always the same: Understanding what kind of problem you're trying to solve and that's what we're going to talk about now. Data analysts work with a variety of problems. In this video, we're going to focus on six common types. These include: making predictions, categorizing things, spotting something unusual, identifying themes, discovering connections, and finding patterns. Let's define each of these now. First, making predictions. This problem type involves using data to make an informed decision about how things may be in the future. For example, a hospital system might use a remote patient monitoring to predict health events for chronically ill patients. The patients would take their health vitals at home every day, and that information combined with data about their age, risk factors, and other important details could enable the hospital's algorithm to predict future health problems and even reduce future hospitalizations. The next problem type is categorizing things. This means assigning information to different groups or clusters based on common features. An example of this problem type is a manufacturer that reviews data on shop floor employee performance. An analyst may create a group for employees who are most and least effective at engineering. A group for employees who are most and least effective at repair and maintenance, most and least effective at assembly, and many more groups or clusters. Next, we have spotting something unusual. In this problem type, data analysts identify data that is different from the norm. An instance of spotting something unusual in the real world is a school system that has a sudden increase in the number of students registered, maybe as big as a 30 percent jump in the number of students. A data analyst might look into this upswing and discover that several new apartment complexes had been built in the school district earlier that year. They could use this analysis to make sure the school has enough resources to handle the additional students. Identifying themes is the next problem type. Identifying themes takes categorization as a step further by grouping information into broader concepts. Going back to our manufacturer that has just reviewed data on the shop floor employees. First, these people are grouped by types and tasks. But now a data analyst could take those categories and group them into the broader concept of low productivity and high productivity. This would make it possible for the business to see who is most and least productive, in order to reward top performers and provide additional support to those workers who need more training. Now, the problem type of discovering connections enables data analysts to find similar challenges faced by different entities, and then combine data and insights to address them. Here's what I mean; say a scooter company is experiencing an issue with the wheels it gets from its wheel supplier. That company would have to stop production until it could get safe, quality wheels back in stock. But meanwhile, the wheel companies encountering the problem with the rubber it uses to make wheels, turns out its rubber supplier could not find the right materials either. If all of these entities could talk about the problems they're facing and share data openly, they would find a lot of similar challenges and better yet, be able to collaborate to find a solution. The final problem type is finding patterns. Data analysts use data to find patterns by using historical data to understand what happened in the past and is therefore likely to happen again. Ecommerce companies use data to find patterns all the time. Data analysts look at transaction data to understand customer buying habits at certain points in time throughout the year. They may find that customers buy more canned goods right before a hurricane, or they purchase fewer cold-weather accessories like hats and gloves during warmer months. The ecommerce companies can use these insights to make sure they stock the right amount of products at these key times. Alright, you've now learned six basic problem types that data analysts typically face. As a future data analyst, this is going to be valuable knowledge for your career. Coming up, we'll talk a bit more about these problem types and I'll provide even more examples of them being solved by data analysts. Personally, I love real-world examples. They really help me better understand new concepts. I can't wait to share even more actual cases with you. See you there.\n\nProblems in the real world\nYou've been learning about six common problem types of data analysts encounter, making predictions, categorizing things, spotting something unusual, identifying themes, discovering connections, and finding patterns. Let's think back to our real world example from a previous video. In that example, anywhere gaming repair wanted to figure out how to bring in new customers. So the problem was, how to determine the best advertising method for anywhere gaming repair's target audience. To help solve this problem, the company used data to envision what would happen if it advertised in different places. Now nobody can see the future but the data helped them make an informed decision about how things would likely work out. So, their problem type was making predictions. Now let's think about the second problem type, categorizing things. Here's an example of a problem that involves categorization. Let's say a business wants to improve its customer satisfaction levels. Data analysts could review recorded calls to the company's customer service department and evaluate the satisfaction levels of each caller. They could identify certain key words or phrases that come up during the phone calls and then assign them to categories such as politeness, satisfaction, dissatisfaction, empathy, and more. Categorizing these key words gives us data that lets the company identify top performing customer service representatives, and those who might need more coaching. This leads to happier customers and higher customer service scores. Okay, now let's talk about a problem that involves spotting something unusual. Some of you may have a smart watch, my favorite app is for health tracking. These apps can help people stay healthy by collecting data such as their heart rate, sleep patterns, exercise routine, and much more. There are many stories out there about health apps actually saving people's lives. One is about a woman who was young, athletic, and had no previous medical problems. One night she heard a beep on her smartwatch, a notification said her heart rate had spiked. Now in this example think of the watch as a data analyst. The watch was collecting and analyzing health data. So when her resting heart rate was suddenly 120 beats per minute, the watch spotted something unusual because according to its data, the rate was normally around 70. Thanks to the data her smart watch gave her, the woman went to the hospital and discovered she had a condition which could have led to life threatening complications if she hadn't gotten medical help. Now let's move on to the next type of problem: identifying themes. We see a lot of examples of this in the user experience field. User experience designers study and work to improve the interactions people have with products they use every day. Let's say a user experience designer wants to see what customers think about the coffee maker his company manufactures. This business collects anonymous survey data from users, which can be used to answer this question. But first to make sense of it all, he will need to find themes that represent the most valuable data, especially information he can use to make the user experience even better. So the problem the user experience designer's company faces, is how to improve the user experience for its coffee makers. The process here is kind of like finding categories for keywords and phrases in customer service conversations. But identifying themes goes even further by grouping each insight into a broader theme. Then the designer can pinpoint the themes that are most common. In this case he learned users often couldn't tell if the coffee maker was on or off. He ended up optimizing the design with improved placement and lighting for the on/off button, leading to the product improvement and happier users. Now we come to the problem of discovering connections. This example is from the transportation industry and uses something called third party logistics. Third party logistics partners help businesses ship products when they don't have their own trucks, planes or ships. A common problem these partners face is figuring out how to reduce wait time. Wait time happens when a truck driver from the third party logistics provider arrives to pick up a shipment but it's not ready. So she has to wait. That costs both companies time and money and it stops trucks from getting back on the road to make more deliveries. So how can they solve this? Well, by sharing data the partner companies can view each other's timelines and see what's causing shipments to run late. Then they can figure out how to avoid those problems in the future. So a problem for one business doesn't cause a negative impact for the other. For example, if shipments are running late because one company only delivers Mondays, Wednesdays and Fridays, and the other company only delivers Tuesdays and Thursdays, then the companies can choose to deliver on the same day to reduce wait time for customers. All right, we've come to our final problem type, finding patterns. Oil and gas companies are constantly working to keep their machines running properly. So the problem is, how to stop machines from breaking down. One way data analysts can do this is by looking at patterns in the company's historical data. For example, they could investigate how and when a particular machine broke down in the past and then generate insights into what led to the breakage. In this case, the company saw pattern indicating that machines began breaking down at faster rates when maintenance wasn't kept up in 15 day cycles. They can then keep track of current conditions and intervene if any of these issues happen again. Pretty cool, right? I'm always amazed to hear about how data helps real people and businesses make meaningful change. I hope you are too. See you soon.\n\nAnmol: From hypothesis to outcome\nHi, I'm Anmol. I'm the Head of Large Advertiser Marketing Analytics within the Marketing Team at Google. At its core, my job is about connecting the right user with the right message at the right time. The first step is really to get a broad sense of the certain pattern that's occurring. So for example, we know that this particular segment of users is more responsive to this type of content. Once we're able to actually see this hypothesis through the data, we do testing to ensure that the hypothesis is actually correct. So for example, we would test sending these pieces of content to this segment of users, and actually verify within a controlled environment whether that response rate is actually higher for that type of content, or whether it isn't. Once we're able to actually verify that hypothesis, we go back to the stakeholders, in this case, our marketers, and say, we've proven within a relatively high degree of certainty that this particular segment is more responsive to this type of content, and because of that, we're recommending that you produce more of this type of content. Our stakeholders really get to see the whole evolution from hypothesis to proven concept, and they're able to come with us on the journey on how we're proving out these hypotheses and then eventually turning them into strategies and recommendations for the business. The outcome in this case was that we were able to actually change the way our whole marketing team worked to actually make it much more user-centric. Instead of, from our perspective, coming up with content that we think the users need, we're actually going in the other direction of figuring out what users need first, proving that they need certain things or they don't need certain things, and then using that information going back to marketers and coming up with content that fulfills their need. So it really changed the direction of how we produce things.\n\nSMART questions\nNow that we've talked about six basic problem types, it's time to start solving them. To do that, data analysts start by asking the right questions. In this video, we're going to learn how to ask effective questions that lead to key insights you can use to solve all kinds of problems. As a data analyst, I ask questions constantly. It's a huge part of the job. If someone requests that I work on a project, I ask questions to make sure we're on the same page about the plan and the goals. And when I do get a result, I question it. Is the data showing me something superficially? Is there a conflict somewhere that needs to be resolved? The more questions you ask, the more you'll learn about your data and the more powerful your insights will be at the end of the day. Some questions are more effective than others. Let's say you're having lunch with a friend and they say, \"These are the best sandwiches ever, aren't they?\" Well, that question doesn't really give you the opportunity to share your own opinion, especially if you happen to disagree and didn't enjoy the sandwich very much. This is called a leading question because it's leading you to answer in a certain way. Or maybe you're working on a project and you decide to interview a family member. Say you ask your uncle, did you enjoy growing up in Malaysia? He may reply, \"Yes.\" But you haven't learned much about his experiences there. Your question was closed-ended. That means it can be answered with a yes or no. These kinds of questions rarely lead to valuable insights. Now what if someone asks you, do you prefer chocolate or vanilla? Well, what are they specifically talking about? Ice cream, pudding, coffee flavoring or something else? What if you like chocolate ice cream but vanilla in your coffee? What if you don't like either flavor? That's the problem with this question. It's too vague and lacks context. Knowing the difference between effective and ineffective questions is essential for your future career as a data analyst. After all, the data analyst process starts with the ask phase. So it's important that we ask the right questions. Effective questions follow the SMART methodology. That means they're specific, measurable, action-oriented, relevant and time-bound. Let's break that down. Specific questions are simple, significant and focused on a single topic or a few closely related ideas. This helps us collect information that's relevant to what we're investigating. If a question is too general, try to narrow it down by focusing on just one element. For example, instead of asking a closed-ended question, like, are kids getting enough physical activities these days? Ask what percentage of kids achieve the recommended 60 minutes of physical activity at least five days a week? That question is much more specific and can give you more useful information. Now, let's talk about measurable questions. Measurable questions can be quantified and assessed. An example of an unmeasurable question would be, why did a recent video go viral? Instead, you could ask how many times was our video shared on social channels the first week it was posted? That question is measurable because it lets us count the shares and arrive at a concrete number. Okay, now we've come to action-oriented questions. Action-oriented questions encourage change. You might remember that problem solving is about seeing the current state and figuring out how to transform it into the ideal future state. Well, action-oriented questions help you get there. So rather than asking, how can we get customers to recycle our product packaging? You could ask, what design features will make our packaging easier to recycle? This brings you answers you can act on. All right, let's move on to relevant questions. Relevant questions matter, are important and have significance to the problem you're trying to solve. Let's say you're working on a problem related to a threatened species of frog. And you asked, why does it matter that Pine Barrens tree frogs started disappearing? This is an irrelevant question because the answer won't help us find a way to prevent these frogs from going extinct. A more relevant question would be, what environmental factors changed in Durham, North Carolina between 1983 and 2004 that could cause Pine Barrens tree frogs to disappear from the Sandhills Regions? This question would give us answers we can use to help solve our problem. That's also a great example for our final point, time-bound questions. Time-bound questions specify the time to be studied. The time period we want to study is 1983 to 2004. This limits the range of possibilities and enables the data analyst to focus on relevant data. Okay, now that you have a general understanding of SMART questions, there's something else that's very important to keep in mind when crafting questions, fairness. We've touched on fairness before, but as a quick reminder, fairness means ensuring that your questions don't create or reinforce bias. To talk about this, let's go back to our sandwich example. There we had an unfair question because it was phrased to lead you toward a certain answer. This made it difficult to answer honestly if you disagreed about the sandwich quality. Another common example of an unfair question is one that makes assumptions. For instance, let's say a satisfaction survey is given to people who visit a science museum. If the survey asks, what do you love most about our exhibits? This assumes that the customer loves the exhibits which may or may not be true. Fairness also means crafting questions that make sense to everyone. It's important for questions to be clear and have a straightforward wording that anyone can easily understand. Unfair questions also can make your job as a data analyst more difficult. They lead to unreliable feedback and missed opportunities to gain some truly valuable insights. You've learned a lot about how to craft effective questions, like how to use the SMART framework while creating your questions and how to ensure that your questions are fair and objective. Moving forward, you'll explore different types of data and learn how each is used to guide business decisions. You'll also learn more about visualizations and how metrics or measures can help create success. It's going to be great!\nMore about SMART questions\nCompanies in lots of industries today are dealing with rapid change and rising uncertainty. Even well-established businesses are under pressure to keep up with what is new and figure out what is next. To do that, they need to ask questions. Asking the right questions can help spark the innovative ideas that so many businesses are hungry for these days.\nThe same goes for data analytics. No matter how much information you have or how advanced your tools are, your data won\u2019t tell you much if you don\u2019t start with the right questions. Think of it like a detective with tons of evidence who doesn\u2019t ask a key suspect about it.  Coming up, you will learn more about how to ask highly effective questions, along with certain practices you want to avoid.\nHighly effective questions are SMART questions:\nExamples of SMART questions\nHere's an example that breaks down the thought process of turning a problem question into one or more SMART questions using the SMART method: What features do people look for when buying a new car?\n\nSpecific: Does the question focus on a particular car feature?\nMeasurable: Does the question include a feature rating system?\nAction-oriented: Does the question influence creation of different or new feature packages?\nRelevant: Does the question identify which features make or break a potential car purchase?\nTime-bound: Does the question validate data on the most popular features from the last three years? \nQuestions should be open-ended. This is the best way to get responses that will help you accurately qualify or disqualify potential solutions to your specific problem. So, based on the thought process, possible SMART questions might be:\n\nOn a scale of 1-10 (with 10 being the most important) how important is your car having four-wheel drive?\nWhat are the top five features you would like to see in a car package?\nWhat features, if included with four-wheel drive, would make you more inclined to buy the car?\nHow much more would you pay for a car with four-wheel drive?\nHas four-wheel drive become more or less popular in the last three years?\nThings to avoid when asking questions\n\nLeading questions: questions that only have a particular response\n\nExample: This product is too expensive, isn\u2019t it?\nThis is a leading question because it suggests an answer as part of the question. A better question might be, \u201cWhat is your opinion of this product?\u201d There are tons of answers to that question, and they could include information about usability, features, accessories, color, reliability, and popularity, on top of price. Now, if your problem is actually focused on pricing, you could ask a question like \u201cWhat price (or price range) would make you consider purchasing this product?\u201d This question would provide a lot of different measurable responses.\n\nClosed-ended questions: questions that ask for a one-word or brief response only\n\nExample: Were you satisfied with the customer trial?\nThis is a closed-ended question because it doesn\u2019t encourage people to expand on their answer. It is really easy for them to give one-word responses that aren\u2019t very informative. A better question might be, \u201cWhat did you learn about customer experience from the trial.\u201d This encourages people to provide more detail besides \u201cIt went well.\u201d\n\nVague questions: questions that aren\u2019t specific or don\u2019t provide context\n\nExample: Does the tool work for you?\nThis question is too vague because there is no context. Is it about comparing the new tool to the one it replaces? You just don\u2019t know. A better inquiry might be, \u201cWhen it comes to data entry, is the new tool faster, slower, or about the same as the old tool? If faster, how much time is saved? If slower, how much time is lost?\u201d These questions give context (data entry) and help frame responses that are measurable (time).\n\nEvan: Data opens doors\n[MUSIC] Hi, I'm Evan. I'm a learning portfolio manager here at Google, and I have one of the coolest jobs in the world where I get to look at all the different technologies that affect big data and then work them into training courses like this one for students to take. I wish I had a course like this when I was first coming out of college or high school. It was honestly a data analyst course that's geared in the way like this one is if you've already taken some of the videos really prepares you to do anything you want. It will open all of those doors that you want for any of those roles inside of the data curriculum. Well, what are some of those roles? There are so many different career paths for someone who's interested in data. Generally, if you're like me, you'll come in through the door as a data analyst maybe working with spreadsheets, maybe working with small, medium, and large databases, but all you have to remember is 3 different core roles. Now there's many in special, whether specialties, within each of these different careers, but these three are the data analysts, which is generally someone who works with SQL, spreadsheets, databases, might work as a business intelligence team creating those dashboards. Now where does all that data come from? Generally, a data analyst will work with a data engineer to turn that raw data into actionable pipelines. So you have data analysts, data engineers, and then lastly, you might have data scientists who basically say the data engineers have built these beautiful pipelines. Sometimes the analyst do that too. The analysts have provided us with clean and actionable data. Then the data scientists then worked actually to turn it into really cool machine learning models or statistical inferences that are just well beyond anything you could have ever imagined. We'll share a lot of resources in links for ways that you can get excited for each of these different roles. And the best part is, if you're like me when I went into school, I didn't know what I wanted to do and you don't have to know at the outset which path you want to go down. Try 'em all. See what you really, really like. It's very personal. Becoming a data analyst is so exciting. Why? Because it's not just like a means to an end. It's just taking a career path where so many bright people have gone before and have made the tools and technologies that much easier for you and me today. For example, when I was starting to learn SQL or the structured query language that you're going to be learning as part of this course, I was doing it on my local laptop and each of the queries would take like 20, 30 minutes to run and it was very hard for me to keep track of different SQL statements that I was writing or share them with somebody else. That was about 10 or 15 years ago. Now, through all the different companies and all the different tools that are making data analysis tools and technologies easier for you, you're going to have a blast creating these insights with a lot less of the overhead that I had when I first started out. So I'm really excited to hear what you think and what your experience is going to be.\n", "source": "coursera_d", "evaluation": "exam"}
{"instructions": ["Question 1. Which of the following examples DO NOT describe using data to achieve business results?\nA. A large retailer performs data analysis on product purchases to create better promotions.\nB. A movie theater tracks the number of weekend movie goers for three months.\nC. A grocery chain collects data on sale items and pricing from each store.\nD. A video streaming service analyzes user preferences to customize movie recommendations.", "Question 2. Which of the following are challenges of using big data? \nA. Data overload\nB. Important data hidden within non-important data\nC. Gaps in many big data business solutions\nD. Learning a programming language to do data cleaning", "Question 3. What are the three Vs of big data?\nA. Volume, Velocity, Veracity\nB. Variety, Velocity, Veracity\nC. Volume, Variety, Visualization\nD. Volume, Variety, Velocity\n", "Question 4. What is the difference between data and metrics?\nA. Data can be used for measurement. Metrics cannot be used for measurement.\nB. Data is quantifiable. Metrics are unquantifiable.\nC. Data is a collection of facts. Metrics are quantifiable data types used for measurement.\nD. Data is quantifiable and used for measurement. Metrics are unorganized collections of facts.", "Question 5. Which of the following is NOT a way that thinking mathematically can help a data analyst\uff1f\nA. By making them a math whiz\nB. By logically breaking down problems step-by-step\nC. By providing solutions by using math and numbers.\nD. By focusing on quantitative data with mathematical tools", "Question 6. Can you outline the functions that a pivot table, a tool commonly utilized in data processing, can undertake? Choose any that are applicable.\nA. Organizing data into groups\nB. Computing totals from the given data\nC. Cleaning up data\nD. Restructuring data", "Question 7. In which of these instances is data being utilized to improve business outcomes? Choose all relevant options.\nA. A sizeable retailer conducts data analytics on product buying patterns to improve promotional strategies.\nB. A cinema monitors the count of attendees during weekends for a quarter of a year.\nC. A supermarket chain aggregates information on discounted items and their prices from all outlets.\nD. An online video platform scrutinizes user likes and dislikes to personalize film suggestions", "Question 8. Which of the following is an example of a metric?\nA. Customer retention rate\nB. The number of customer reviews\nC. A list of sales transactions\nD. A database of product information", "Question 9. What is the main difference between a report and a dashboard in data visualization?\nA. A report is dynamic, while a dashboard is static.\nB. A report is static, while a dashboard is dynamic.\nC. A report is always visually appealing, while a dashboard is not.\nD. A report is less efficient than a dashboard in all cases.", "Question 10. What is the main purpose of using metrics in data analysis?\nA. To turn raw data into useful information\nB. To create visually appealing dashboards\nC. To organize unimportant data\nD. To focus only on qualitative data", "Question 11. Return on Investment (ROI) uses which of the following metrics in its definition?\nA. Profit and investment\nB. Supply and demand\nC. Sales and margin\nD. Inventory and units", "Question 12. Describe the key differences between small data and big data. Select all that apply.\nA. Small data is effective for analyzing day-to-day decisions. Big data is effective for analyzing more substantial decisions.\nB. Small data involves datasets concerned with a small number of specific metrics. Big data involves datasets that are larger and less specific.\nC. Small data focuses on short, well-defined time periods. Big data focuses on change over a long period of time.\nD. Small data is typically stored in a database. Big data is typically stored in a spreadsheet.", "Question 13. Which option below represents a case of small data?\nA. The bed occupancy rate for a hospital over the last ten years.\nB. The trade deficit between two countries over a century.\nC. The cumulative absences of all high school students.\nD. The daily step count of an individual."], "outputs": ["BC", "ABC", "D", "C", "ACD", "ABD", "AD", "AB", "B", "A", "A", "ABC", "D"], "input": "Data and decisions\nWelcome back. Now it's time to go even further and build on what you've learned about problem-solving in data analytics and crafting effective questions. Coming up, we'll cover a wide range of topics. You'll learn about how data can empower our decisions, big and small; the difference between quantitative and qualitative analysis and when to use them; the pros and cons of different data visualization tools; what metrics are, and how analysts use them; and how to use mathematical thinking to connect the dots. To be honest, I'm still learning more about these things every day, and so will you! Like how quantitative and qualitative data can work together. In my role in finance, most of my work is quantitative, but recently I was working on a project that focused a lot on empathy and trust and that was really new for me. But we took those more qualitative things into account during analysis, and that really helped me understand how quantitative and qualitative data can come together to help us make powerful decisions. Now you're on your way to building your own data analyst toolkit. Before you know it, you'll be analyzing all kinds of data yourself and learning new things while you do it. But first, let's start small with the power of observation.\n\nHow data empowers decisions\nWe've talked a lot about what data is and how it plays into decision-making. What do we know already? Well, we know that data is a collection of facts. We also know that data analysis reveals important patterns and insights about that data. Finally, we know that data analysis can help us make more informed decisions. Now, we'll look at how data plays into the decision-making process and take a quick look at the differences between data-driven and data-inspired decisions. Let's look at a real-life example. Think about the last time you searched \"restaurants near me\" and sorted the results by rating to help you decide which one looks best. That was a decision you made using data. Businesses and other organizations use data to make better decisions all the time. There's two ways they can do this, with data-driven or data-inspired decision-making. We'll talk more about data-inspired decision-making later on, but here's a quick definition for now. Data-inspired decision-making explores different data sources to find out what they have in common. Here at Google, we use data every single day, in very surprising ways too. For example, we use data to help cut back on the amount of energy spent cooling your data centers. After analyzing years of data collected with artificial intelligence, we were able to make decisions that help reduce the energy we use to cool our data centers by over 40 percent. Google's People Operations team also uses data to improve how we hire new Googlers and how we get them started on the right foot. We wanted to make sure we weren't passing over any talented applicants and that we made their transition into their new roles as smooth as possible. After analyzing data on applications, interviews, and new hire orientation processes, we started using an algorithm. An algorithm is a process or set of rules to be followed for a specific task. With this algorithm, we reviewed applicants that didn't pass the initial screening process to find great candidates. Data also helped us determine the ideal number of interviews that lead to the best possible hiring decisions. We've created new onboarding agendas to help new employees get started at their new jobs. Data is everywhere. Today, we create so much data that scientists estimate 90 percent of the world's data has been created in just the last few years. Think of the potential here. The more data we have, the bigger the problems we can solve and the more powerful our solutions can be. But responsibly gathering data is only part of the process. We also have to turn data into knowledge that helps us make better solutions. I'm going to let fellow Googler, Ed, talk more about that. Just having tons of data isn't enough. We have to do something meaningful with it. Data in itself provides little value. To quote Jack Dorsey, the founder of Twitter and Square, \"Every single action that we do in this world is triggering off some amount of data, and most of that data is meaningless until someone adds some interpretation of it or someone adds a narrative around it.\" Data is straightforward, facts collected together, values that describe something. Individual data points become more useful when they're collected and structured, but they're still somewhat meaningless by themselves. We need to interpret data to turn it into information. Look at Michael Phelps' time in a 200-meter individual medal swimming race, one minute, 54 seconds. Doesn't tell us much. When we compare it to his competitor's times in the race, however, we can see that Michael came in the first place and won the gold medal. Our analysis took data, in this case, a list of Michael's races and times and turned it into information by comparing it with other data. Context is important. We needed to know that this race was an Olympic final and not some other random race to determine that this was a gold medal finish. But this still isn't knowledge. When we consume information, understand it, and apply it, that's when data is most useful. In other words, Michael Phelps is a fast swimmer. It's pretty cool how we can turn data into knowledge that helps us in all kinds of ways, whether it's finding the perfect restaurant or making environmentally friendly changes. But keep in mind, there are limitations to data analytics. Sometimes we don't have access to all of the data we need, or data is measured differently across programs, which can make it difficult to find concrete examples. We'll cover these more in detail later on, but it's important that you start thinking about them now. Now that you know how data drives decision-making, you know how key your role as a data analyst is to the business. Data is a powerful tool for decision-making, and you can help provide businesses with the information they need to solve problems and make new decisions, but before that, you will need to learn a little more about the kinds of data you'll be working with and how to deal with it.\n\nQualitative and quantitative data\nHi again. When it comes to decision-making, data is key. But we've also learned that there are a lot of different kinds of questions that data might help us answer, and these different questions make different kinds of data. There are two kinds of data that we'll talk about in this video, quantitative and qualitative. Quantitative data is all about the specific and objective measures of numerical facts. This can often be the what, how many, and how often about a problem. In other words, things you can measure, like how many commuters take the train to work every week. As a financial analyst, I work with a lot of quantitative data. I love the certainty and accuracy of numbers. On the other hand, qualitative data describes subjective or explanatory measures of qualities and characteristics or things that can't be measured with numerical data, like your hair color. Qualitative data is great for helping us answer why questions. For example, why people might like a certain celebrity or snack food more than others. With quantitative data, we can see numbers visualized as charts or graphs. Qualitative data can then give us a more high-level understanding of why the numbers are the way they are. This is important because it helps us add context to a problem. As a data analyst, you'll be using both quantitative and qualitative analysis, depending on your business task. Reviews are a great example of this. Think about a time you used reviews to decide whether you wanted to buy something or go somewhere. These reviews might have told you how many people dislike that thing and why. Businesses read these reviews too, but they use the data in different ways. Let's look at an example of a business using data from customer reviews to see qualitative and quantitative data in action. Now, say a local ice cream shop has started using their online reviews to engage with their customers and build their brand. These reviews give the ice cream shop insights into their customers' experiences, which they can use to inform their decision-making. The owner notices that their rating has been going down. He sees that lately his shop has been receiving more negative reviews. He wants to know why, so he starts asking questions. First are measurable questions. How many negative reviews are there? What's the average rating? How many of these reviews use the same keywords? These questions generate quantitative data, numerical results that help confirm their customers aren't satisfied. This data might lead them to ask different questions. Why are customers unsatisfied? How can we improve their experience? These are questions that lead to qualitative data. After looking through the reviews, the ice cream shop owner sees a pattern, 17 of negative reviews use the word \"frustrated.\" That's quantitative data. Now we can start collecting qualitative data by asking why this word is being repeated? He finds that customers are frustrated because the shop is running out of popular flavors before the end of the day. Knowing this, the ice cream shop can change its weekly order to make sure it has enough of what the customers want. With both quantitative and qualitative data, the ice cream shop owner was able to figure out his customers were unhappy and understand why. Having both types of data made it possible for him to make the right changes and improve his business. Now that you know the difference between quantitative and qualitative data, you know how to get different types of data by asking different questions. It's your job as a data detective to know which questions to ask to find the right solution. Then you can start thinking about cool and creative ways to help stakeholders better understand the data. For example, interactive dashboards, which we'll learn about soon.\n\nThe big reveal: Sharing your findings\nData is great, but if we can't communicate the story data is telling, it isn't useful to anyone. We need ways to organize data that help us turn it into information. There are all kinds of tools out there to help you visualize and share your data analysis with stakeholders. Here, we'll talk about two data presentation tools, reports and dashboards. Reports and dashboards are both useful for data visualization. But there are pros and cons for each of them. A report is a static collection of data given to stakeholders periodically. A dashboard on the other hand, monitors live, incoming data. Let's talk about reports first. Reports are great for giving snapshots of high level historical data for an organization. For example, a finance firm's monthly sales. Reports come with a lot of benefits too. They can be designed and sent out periodically, often on a weekly or monthly basis, as organized and easy to reference information. They're quick to design and easy to use as long as you continually maintain them. Finally, because reports use static data or data that doesn't change once it's been recorded, they reflect data that's already been cleaned and sorted. There are some downsides to keep in mind too. Reports need regular maintenance and aren't very visually appealing. Because they aren't automatic or dynamic, reports don't show live, evolving data. For a live reflection of incoming data, you'll want to design a dashboard. Dashboards are great for a lot of reasons, they give your team more access to information being recorded, you can interact through data by playing with filters, and because they're dynamic, they have long-term value. If stakeholders need to continually access information, a dashboard can be more efficient than having to pull reports over and over, which is a big time saver for you. Last but not least, they're just nice to look at. But dashboards do have some cons too. For one thing, they take a lot of time to design and can actually be less efficient than reports, if they're not used very often. If the base table breaks at any point, they need a lot of maintenance to get back up and running again. Dashboards can sometimes overwhelm people with information too. If you aren't used to looking through data on a dashboard, you might get lost in it. As a data analyst, you need to decide the best way to communicate information to your stakeholders. For example, what if your stakeholders are interested in the company's social media engagement? Would a monthly report that tells them the number of new followers for their page be useful? Or a dashboard that monitors live social media engagement across multiple platforms? Later on, you'll create your own reports and dashboards to practice using these tools. But for now, I want to show you what a report and a dashboard might look like. We'll start by using a tool we're already familiar with, spreadsheets. Let's see one way spreadsheet data could be visualized in a report. This spreadsheet has a data set with order details from a wholesale company. That's a lot of information. From the headers, we can see different things recorded here, like the order date, the salesperson, the unit price, and revenue for each transaction recorded. It's all useful information, but a little hard to wrap your head around. We want a report that's easier to read. Let's say your stakeholders want a quick look at the revenue by salesperson. Using the data, you could make them a pivot table with a graph that shows that information. A pivot table is a data summarization tool that is used in data processing. Pivot tables are used to summarize, sort, re-organize, group, count, total, or average data stored in a database. It allows its users to transform columns into rows and rows into columns. We'll actually learn more about pivot tables later. But I'll show you one really quick. We'll select the Data menu and click Pivot table button. It can pull data from this table. We can just press create and it'll pull up a new worksheet. Over here, it gives us the pivot table fields we can choose from. Click select, salesperson and revenue. Just like that, it made a chart for us. At this point, you can play around with how the graph looks, but the information is all there. Let's move on to dashboards. If you need a more dynamic way to share information with your stakeholders, dashboards are your friend. You might create something like this Tableau dashboard. With interactive graphs that showcase multiple views of the data. With this, users can change location, date range, or any other aspect of the data they're viewing by clicking through different elements on the dashboard. Pretty cool, right? Later in this program, we'll look into how you can make your own data visualizations. We have a lot to learn before we get to that. But I hope this was an exciting first peek at the different visualization tools you'll be using as a data analyst.\n\nData versus metrics\n\nIn the last video, we learned how you can visualize your data using reports and \ndashboards to show off your findings in interesting ways. \nIn one of our examples, \nthe company wanted to see the sales revenue of each salesperson. \nThat specific measurement of data is done using metrics. \nNow, I want to tell you a little bit more about the difference between data and \nmetrics. \nAnd how metrics can be used to turn data into useful information. \nA metric is a single, quantifiable type of data that can be used for measurement. \nThink of it this way. \nData starts as a collection of raw facts, until we organize \nthem into individual metrics that represent a single type of data. \nMetrics can also be combined into formulas that you can plug \nyour numerical data into. \nIn our earlier sales revenue example all that data doesn't mean much \nunless we use a specific metric to organize it. \nSo let's use revenue by individual salesperson as our metric. \nNow we can see whose sales brought in the highest revenue. \nMetrics usually involve simple math. \nRevenue, for example, is the number of sales multiplied by the sales price. \nChoosing the right metric is key. \nData contains a lot of raw details about the problem we're exploring. \nBut we need the right metrics to get the answers we're looking for. \nDifferent industries will use all kinds of metrics to measure things in a data set. \nLet's look at some more ways businesses in different industries use metrics. \nSo you can see how you might apply metrics to your collected data. \nEver heard of ROI? \nCompanies use this metric all the time. \nROI, or Return on Investment is essentially a formula designed using \nmetrics that let a business know how well an investment is doing. \nThe ROI is made up of two metrics, \nthe net profit over a period of time and the cost of investment. \nBy comparing these two metrics, profit and cost of investment, the company \ncan analyze the data they have to see how well their investment is doing. \nThis can then help them decide how to invest in the future and \nwhich investments to prioritize. \nWe see metrics used in marketing too. \nFor example, metrics can be used to help calculate customer retention rates, \nor a company's ability to keep its customers over time. \nCustomer retention rates can help the company compare the number of customers at \nthe beginning and the end of a period to see their retention rates. \nThis way the company knows how successful their marketing strategies are \nand if they need to research new approaches to bring back more repeat \ncustomers. \nDifferent industries use all kinds of different metrics. \nBut there's one thing they all have in common: \nthey're all trying to meet a specific goal by measuring data. \nThis metric goal is a measurable goal set by a company and evaluated using metrics. \nAnd just like there are a lot of possible metrics, \nthere are lots of possible goals too. \nMaybe an organization wants to meet a certain number of monthly sales, \nor maybe a certain percentage of repeat customers. \nBy using metrics to focus on individual aspects of your data, you can start to see the story your data is telling. Metric goals and formulas are great ways to measure and understand data. But they're not the only ways. We'll talk more about how to interpret and understand data throughout this course.\nMathematical thinking\nSo far, you've learned a lot about how to think like a data analyst. We've explored a few different ways of thinking. And now, I want to take that one step further by using a mathematical approach to problem-solving. Mathematical thinking is a powerful skill you can use to help you solve problems and see new solutions. So, let's take some time to talk about what mathematical thinking is, and how you can start using it. Using a mathematical approach doesn't mean you have to suddenly become a math whiz. It means looking at a problem and logically breaking it down step-by-step, so you can see the relationship of patterns in your data, and use that to analyze your problem. This kind of thinking can also help you figure out the best tools for analysis because it lets us see the different aspects of a problem and choose the best logical approach. There are a lot of factors to consider when choosing the most helpful tool for your analysis. One way you could decide which tool to use is by the size of your dataset. When working with data, you'll find that there's big and small data. Small data can be really small. These kinds of data tend to be made up of datasets concerned with specific metrics over a short, well defined period of time. Like how much water you drink in a day. Small data can be useful for making day-to-day decisions, like deciding to drink more water. But it doesn't have a huge impact on bigger frameworks like business operations. You might use spreadsheets to organize and analyze smaller datasets when you first start out. Big data on the other hand has larger, less specific datasets covering a longer period of time. They usually have to be broken down to be analyzed. Big data is useful for looking at large- scale questions and problems, and they help companies make big decisions. When you're working with data on this larger scale, you might switch to SQL. Let's look at an example of how a data analyst working in a hospital might use mathematical thinking to solve a problem with the right tools. The hospital might find that they're having a problem with over or under use of their beds. Based on that, the hospital could make bed optimization a goal. They want to make sure that beds are available to patients who need them, but not waste hospital resources like space or money on maintaining empty beds. Using mathematical thinking, you can break this problem down into a step-by-step process to help you find patterns in their data. There's a lot of variables in this scenario. But for now, let's keep it simple and focus on just a few key ones. There are metrics that are related to this problem that might show us patterns in the data: for example, maybe the number of beds open and the number of beds used over a period of time. There's actually already a formula for this. It's called the bed occupancy rate, and it's calculated using the total number of inpatient days, and the total number of available beds over a given period of time. What we want to do now is take our key variables and see how their relationship to each other might show us patterns that can help the hospital make a decision. To do that, we have to choose the tool that makes sense for this task. Hospitals generate a lot of patient data over a long period of time. So logically, a tool that's capable of handling big datasets is a must. SQL is a great choice. In this case, you discover that the hospital always has unused beds. Knowing that, they can choose to get rid of some beds, which saves them space and money that they can use to buy and store protective equipment. By considering all of the individual parts of this problem logically, mathematical thinking helped us see new perspectives that led us to a solution. Well, that's it for now. Great job. You've covered a lot of material already. You've learned about how empowering data can be in decision-making, the difference between quantitative and qualitative analysis, using reports and dashboards for data visualization, metrics, and using a mathematical approach to problem-solving. Coming up next, we'll be tackling spreadsheet basics. You'll get to put what you've learned into action and learn a new tool to help you along the data analysis process. See you soon.\nBig and small data\nAs a data analyst, you will work with data both big and small. Both kinds of data are valuable, but they play very different roles. \n \nWhether you work with big or small data, you can use it to help stakeholders improve business processes, answer questions, create new products, and much more. But there are certain challenges and benefits that come with big data and the following table explores the differences between big and small data.\nSmall data\tBig data\nDescribes a data set made up of specific metrics over a short, well-defined time period\tDescribes large, less-specific data sets that cover a long time period\nUsually organized and analyzed in spreadsheets\tUsually kept in a database and queried\nLikely to be used by small and midsize businesses\tLikely to be used by large organizations\nSimple to collect, store, manage, sort, and visually represent \tTakes a lot of effort to collect, store, manage, sort, and visually represent\nUsually already a manageable size for analysis\tUsually needs to be broken into smaller pieces in order to be organized and analyzed effectively for decision-making\nChallenges and benefits\nHere are some challenges you might face when working with big data:\n\u2022\tA lot of organizations deal with data overload and way too much unimportant or irrelevant information. \n\u2022\tImportant data can be hidden deep down with all of the non-important data, which makes it harder to find and use. This can lead to slower and more inefficient decision-making time frames.\n\u2022\tThe data you need isn\u2019t always easily accessible. \n\u2022\tCurrent technology tools and solutions still struggle to provide measurable and reportable data. This can lead to unfair algorithmic bias. \n\u2022\tThere are gaps in many big data business solutions.\nNow for the good news! Here are some benefits that come with big data:\n\u2022\tWhen large amounts of data can be stored and analyzed, it can help companies identify more efficient ways of doing business and save a lot of time and money.\n\u2022\tBig data helps organizations spot the trends of customer buying patterns and satisfaction levels, which can help them create new products and solutions that will make customers happy.\n\u2022\tBy analyzing big data, businesses get a much better understanding of current market conditions, which can help them stay ahead of the competition.\n\u2022\tAs in our earlier social media example, big data helps companies keep track of their online presence\u2014especially feedback, both good and bad, from customers. This gives them the information they need to improve and protect their brand.\nThe three (or four) V words for big data\nWhen thinking about the benefits and challenges of big data, it helps to think about the three Vs: volume, variety, and velocity. Volume describes the amount of data. Variety describes the different kinds of data. Velocity describes how fast the data can be processed. Some data analysts also consider a fourth V: veracity. Veracity refers to the quality and reliability of the data. These are all important considerations related to processing huge, complex data sets. \nVolume\tVariety\tVelocity\tVeracity\nThe amount of data\tThe different kinds of data \tHow fast the data can be processed\tThe quality and reliability of the data\n", "source": "coursera_d", "evaluation": "exam"}
{"instructions": ["Question 1. Which of the following functions can be used to calculate the average of a range of cells in a spreadsheet? Select all that apply.\nA. AVERAGE\nB. MEAN\nC. MEDIAN\nD. MODE", "Question 2. What is the purpose of using cell references in formulas?\nA. To automatically update the formula when copied to a new cell\nB. To avoid errors when data changes\nC. To make calculations based on specific cells\nD. To create a more visually appealing spreadsheet", "Question 3. Which of the following functions return the minimum value in a range of cells? Select all that apply.\nA. MIN\nB. MINIMUM\nC. LOWEST\nD. SMALLEST", "Question 4. In order to avoid the DIV error in a spreadsheet, which function can be used?\nA. ISERROR\nB. ERROR\nC. DIV\nD. IFERROR\n", "Question 5. What does the NAME error in a spreadsheet indicate?\nA. A formula's name isn't recognized or understood\nB. A cell reference is missing\nC. A formula is trying to divide by zero\nD. A formula contains inconsistent data", "Question 6. Within a spreadsheet, data analysts use which tools to save time and effort by automating commands? Select all that apply.\nA. Tables\nB. Filters\nC. Functions\nD. Formulas", "Question 7. Which of the following operators are used for multiplication and division in spreadsheets? Select all that apply.\nA. Asterisk (*)\nB. Forward slash (/)\nC. Plus sign (+)\nD. Hyphen (-)", "Question 8. What is the purpose of using a scope of work in data analysis? Select all that apply.\nA. To outline the work to be performed on a project\nB. To provide a timeline for major tasks and activities\nC. To ensure consistency in data analysis\nD. To create checkpoints for progress monitoring", "Question 9. What is the main goal of structured thinking in data analysis?\nA. To recognize the current problem or situation\nB. To organize available information\nC. To reveal gaps and opportunities\nD. To address problems by breaking them down into manageable parts and examining each of these components", "Question 10. Which of the following errors in a spreadsheet indicates that a formula's calculation cannot be performed as specified by the data?\nA. VALUE error\nB. REF error\nC. N/A error\nD. NUM error", "Question 11. What is the importance of contextualizing data in data analysis?\nA. To understand the relationships between data points\nB. To avoid bias in data interpretation\nC. To provide a more accurate representation of the population\nD. To ignore external factors impacting the data", "Question 12. To visualize data, data analysts use which of the following graphs or charts? Select all that apply.\nA. Bar graph\nB. Area chart\nC. Feature graph\nD. String chart", "Question 13. To address a vague, complex problem, data analysts break it down into smaller steps. They use a process that helps them recognize the current problem or situation. Then, they organize available information, reveal gaps and opportunities, and identify the options. What process does this scenario describe?\nA. Structured thinking\nB. Analytical thinking\nC. Gap analysis\nD. Data-driven decision-making"], "outputs": ["A", "ABC", "A", "D", "B", "CD", "AB", "ABD", "ABC", "D", "ABC", "AB", "A"], "input": "The amazing spreadsheet\nHi, again. I'm glad you're back. In this part of the program, we'll revisit the spreadsheet. Spreadsheets are a powerful and versatile tool, which is why they're a big part of pretty much everything we do as data analysts. There's a good chance a spreadsheet will be the first tool you reach for when trying to answer data-driven questions. After you've defined what you need to do with the data, you'll turn to spreadsheets to help build evidence that you can then visualize, and use to support your findings. Spreadsheets are often the unsung heroes of the data world. They don't always get the appreciation they deserve, but as a data detective, you'll definitely want them in your evidence collection kit. I know spreadsheets have saved the day for me more than once. I've added data for purchase orders into a sheet, setup formulas in one tab, and had the same formulas do the work for me in other tabs. This frees up time for me to work on other things during the day. I couldn't imagine not using spreadsheets. Math is a core part of every data analyst's job, but not every analyst enjoys it. Luckily, spreadsheets can make calculations more enjoyable, and by that, I mean easier. Let's see how. Spreadsheets can do both basic and complex calculations automatically. Not only does this help you work more efficiently, but it also lets you see the results and understand how you got them. Here's a quick look at some of the functions that you'll use when performing calculations. Many functions can be used as part of a math formula as well. Functions and formulas also have other uses, and we'll take a look at those too. We'll take things one step further with exercises that use real data from databases. This is your chance to reorganize a spreadsheet, do some actual data analysis, and have some fun with data.\n\nGet to work with spreadsheets\nData analysts spend a lot of time organizing data and performing calculations. Luckily, there's lots of different tools to help them do just that, including spreadsheets. In this video we'll take a look at some of the ways data analysts use spreadsheets to help them with their day to day responsibilities. Later, you'll get to test out some of these things yourself, but for now, let's start with a quick look at how data analysts use spreadsheets to do their jobs. This will change depending on the work you need to complete. But here's an overview of a few of the major tasks. Imagine you work for a construction company. Your company needs your spreadsheet skills to analyze some data about their expenses, so you access the appropriate data and add it to your spreadsheet. We won't cover all the details of this project right now, but you will get a chance to see lots of spreadsheet features up close and personal as we move forward. What do you do with the data now that it's in your spreadsheet? Again, this will be different for each job, but you might start by organizing your data with the task you've been given. For example, you might put your data in a pivot table. We've talked about pivot tables before in this course. We'll cover them in more detail later on, but for now, just think of them as well organized and very useful tables. Next, you might filter the data in the pivot table. Sorting and filtering data is a common part of most jobs. This lets you focus only on the data you'll need for your analysis. In our example, maybe you only need the expenses for a certain time frame, like the last three months. After you filtered your data, you could perform some calculations to learn more about it. Maybe you need to find out which construction projects ended up costing the most money. This is where formulas and functions are really handy. We'll talk about them in just a bit, but formulas and functions are great for doing some quick math, especially once you run out of fingers and toes to count on. Now you've seen some of the ways data analysts are using spreadsheets in their day to day work for a lot of different tasks, including organizing their data and making calculations. Before you know it we'll have you working in your own spreadsheets.\n\nSpreadsheets and the data life cycle\n\nTo better understand the benefits of using spreadsheets in data analytics, let\u2019s explore how they relate to each phase of the data life cycle: plan, capture, manage, analyze, archive, and destroy.\n\u2022\tPlan for the users who will work within a spreadsheet by developing organizational standards. This can mean formatting your cells, the headings you choose to highlight, the color scheme, and the way you order your data points. When you take the time to set these standards, you will improve communication, ensure consistency, and help people be more efficient with their time.\n\u2022\tCapture data by the source by connecting spreadsheets to other data sources, such as an online survey application or a database. This data will automatically be updated in the spreadsheet. That way, the information is always as current and accurate as possible.\n\u2022\tManage different kinds of data with a spreadsheet. This can involve storing, organizing, filtering, and updating information. Spreadsheets also let you decide who can access the data, how the information is shared, and how to keep your data safe and secure. \n\u2022\tAnalyze data in a spreadsheet to help make better decisions. Some of the most common spreadsheet analysis tools include formulas to aggregate data or create reports, and pivot tables for clear, easy-to-understand visuals. \n\u2022\tArchive any spreadsheet that you don\u2019t use often, but might need to reference later with built-in tools. This is especially useful if you want to store historical data before it gets updated. \n\u2022\tDestroy your spreadsheet when you are certain that you will never need it again, if you have better backup copies, or for legal or security reasons. Keep in mind, lots of businesses are required to follow certain rules or have measures in place to make sure data is destroyed properly. \n\nStep-by-step in spreadsheets\nWe've talked about how spreadsheets are great for organizing data and performing calculations. Now, it's time to get our hands dirty and start building a real spreadsheet. In this video, I'm going to demonstrate some basic tasks we know data analysts use spreadsheets for, including entering and organizing data. We'll start with a step-by-step process to show you some tools to organize your data in a spreadsheet. Consider these steps the basics. You won't always have to use them when working with a data set, but if your data is a bit messy when you get it, these steps can help you get it ready for analysis. Let's start by opening a new spreadsheet. As a data analyst, you might not start with a blank spreadsheet, but it's good to know how to do it, just in case. Start by opening Excel, Google Sheets or whatever spreadsheet software you're using, then select a new blank file. The first thing you'll want to do when you open a new spreadsheet is give it a title. Here's a pro tip. Make your title short, clear, and have it state exactly what the data in the spreadsheet is about. Trust me, it'll make searching for it a lot easier. Creating a folder on your computer specifically for spreadsheets and related files can also make it easier to find them. For this spreadsheet, it's already saved in our drive. So we'll open our File menu to click Move. Then we'll create a new folder, \nname it \"Population Data,\" \nand move the spreadsheet there. \nOur spreadsheet now has a new home. This will save you a lot of unnecessary clicks and headaches when you look for this file. There's a few different ways data analysts get data they work with. Depending on the job, you might use data from an open source, you might be given data to work with or you might be asked to find your own data. You'll experience all of these later in the program. There's a lot of open data sources online, where data is made available to the public. For example, we'll use data from worldbank.org, that's already in the spreadsheet. The data shows the population of Latin American and Caribbean countries from 2010-2019. Let's open this spreadsheet. Time to get the data ready for analysis. We'll start by selecting the whole sheet and making our columns wider by dragging the boundary of one of the columns. This will help us see the data clearly, then we can adjust any individual columns that need it. You can make columns wider in other ways as well, but this will work for now. The first row of the spreadsheet is for data attributes or variables. It's basically labeling the type of data in each column. Let's make the attributes stand out from the rest of the rows by selecting it and filling it with color. We'll also make the labels bold. If we want to add another data attribute between two of the other attributes, we can always add a new column. Just click on any cell within a column and use the Insert menu to add a new one. It will appear next to the column you originally clicked, pretty simple. Deleting a column is just as simple. To delete, right-click in a cell in the column you want to get rid of. The steps we're showing may be different depending on the spreadsheet program you're using, but should be pretty similar. Let's add one more thing to our data table: borders. This can help you see each piece of data more clearly. To add borders start by clicking the Select All button at the top left corner of your spreadsheet. This is like a magic button because you can click it whenever you need to make changes to every cell in your spreadsheet. Then click the Border button in the menu, and choose the type of borders you want. To keep our spreadsheets uniform, we'll choose borders for all cells. Just like that, we've gone from raw to refined. Now our spreadsheet is filled with data and it's nice to look at too. Using these organization tools before you analyze can help you focus on the data once you start your analysis. Now that we've gone over some ways spreadsheets can be used to organize data, you're ready to start working on them yourself. Later you'll learn more about spreadsheets, including some common errors and how to fix them.\n\nFormulas for success\nSo far we've covered how to start a new spreadsheet, enter in data, and make it look refined and ready for some serious analysis. Now we'll learn how to perform calculations in your spreadsheet. You may need to calculate everything from sums to averages, to finding minimum and maximum amounts. You'll use calculations for a lot of different kinds of tasks. In this video, we'll focus on learning the basics and then do a little math with some sales data to practice. Let's talk about formulas first. You might remember that a formula is a set of instructions that perform a specific calculation. Basically, formulas can do the math for you. Now, they don't only do math, they can do a lot more. Soon you'll learn different ways you can use them throughout the data analysis processes. Formulas are built on operators which are symbols that name the type of operation or calculation to be performed. For example, a plus sign is a common operator. The formulas you use as a data analyst will usually include at least one operator. Now, let's talk about math expressions or equations. These can take a lot of different forms, but you might be familiar with them already. 3 minus 1, 15 plus 8 divided by 2, 846 times 513. These are all examples of expressions. Is this bringing back memories of grade school? Well, back in math class, you most likely learned to complete an expression by including an equal sign and the solution. It's slightly different with spreadsheets. When you create a formula using an expression in a spreadsheet, you start the formula with an equal sign. For example, if we want to subtract, we type an equal sign followed by the rest of the expression without any spaces in the formula. Now let's try an expression that's a bit more challenging. We'll type 31982, then a hyphen for a minus sign, then 17795. To calculate, we press \"Enter.\" You'll most likely use formulas this way when dealing with large numbers or expressions with multiple steps. Here are the operators you will use to complete formulas. The plus sign for addition, the minus or hyphen for subtraction, the asterisk for multiplication, and the forward slash for division. The division and multiplication symbols might be different than what you're used to. Small changes, but important to keep in mind. If you already have data in your spreadsheet, you can use cell references in your formulas instead. A cell reference is a single cell or range of cells in a worksheet that can be used in a formula. Cell references contain the letter of the column and the number of the row where the data is. A range of cells is a collection of two or more cells. A range can include cells from the same row or column, or from different columns and rows collected together. We'll show you an example in an upcoming video. Now let's apply what we just learned to some sales data. If we want to add these figures to find the total sales for the first row of data, you can click \"cell F2\". From there, we'll start with an equal sign and use the cell references to input values in your expression. We're starting with cell B2 because the year in A2 is not a value we want to add to the total.\nThen press \"Enter.\" Just like that, your total sales has been calculated for you, but what if you realized one of the values in your data was wrong? No problem. You can change the value in any cell using the formula and the total will update automatically.\nThe great thing about using cell references is that they also automatically update when a formula is copied to a new cell. Talk about a time-saver. Instead of entering the same formula again for every new set of cell references, just copy the formula using the menu or a keyboard shortcut like Control plus C.\nThen paste the formula where you want to apply it using Control plus V. And presto! The formula updates all the new cells and values correctly. Now let's say you also want it to find the average sales. For this, you create a new formula in a different cell.\nTo group values in a formula, use parentheses. This lets your spreadsheet know which values to calculate together and the order of the operations to be performed. For example, open parentheses, then B2 plus C2 plus D2 plus E2, and close parentheses, then divide the value of all of this by typing slash four. You are adding the values in the four cells together and then using the slash to divide the total by four, and just like the last one, we can copy and paste the formula. Here's another formula you can use if you want to find the percent change in sales between June and July.\nOnce a formula calculates the value, you can then use the percent button to change the value to a percentage. When you apply the formula to the other rows, both the formula and the percent will automatically update. That doesn't look like the right answer. Looks like we've got an error. Don't worry. Errors can happen at any stage of data analysis, and that includes when you're using spreadsheets. A formula has to be air tight. If there's something wrong with one of the cell references, it won't work. So what's our error? Well, we can see that the value in cell D4 is missing. It might take some time and research on your part to find the correct value, but it's worth it. You want your analysis to be as accurate as possible. When you do add the value, the formula takes care of the rest.\nThat was a lot to take in. Thanks for staying with me. You'll be able to apply what you learned about formulas here and later in the program to make your analysis more efficient and your job, a little easier, and soon you'll work in your own spreadsheet. Happy spreadsheeting.\n\nSpreadsheet errors and fixes\nHi and welcome back. Recently we've been learning about formulas. Sometimes data analysts encounter a problem with our formulas and we get an error. We've all been there and it can be frustrating. But there are solutions, that's what we're going to explore in this video. One error you may encounter is the DIV error. The DIV error happens when a formula is trying to divide a value in a cell by zero or by an empty cell. In this spreadsheet, the percentage Complete values in column C are calculated by dividing the values in the Tasks Completed column by the values in the Required Tasks column. Notice that column C is already formatted as a percentage. The DIV error is in cell C4 because we're dividing by zero the value in cell A4. To avoid this problem, we can have this spreadsheet automatically enter not applicable whenever a cell in column A contains a zero that would cause the error. To do this, we'll use the IFERROR function. If it encounters a DIV error caused by a cell that contains the zero, the phrase \"Not applicable\" will be inserted.\nWe can also copy the formula to the rest of the cells in column C so it checks for any other cells that contain a zero. Now let's move on to ERROR. In Google Sheets, ERROR tells us the formula can't be interpreted as it is input. This is also known as a parsing error. Say we want to tally the number of total tasks in column B and C, we use the SUM function, but the formula equal sum B2 to B6, C2 to C6 causes an error. Examining it more closely, we see that a comma is missing between the cell ranges B2 to B6 and C2 to C6. We can fix this by inserting a comma between the cell ranges to indicate the end of each data item. This is called a delimiter, which you will learn more about soon. Now, the formula can correctly calculate the total number of tasks as 25. Another type of error is N/A. The N/A error tells you that the data in your formula can't be found by the spreadsheet. Generally, this means the data doesn't exist. This error most often occurs when using functions such as VLOOKUP, which searches for a certain value in a column to return a corresponding piece of information. Here, we see a master list of nuts and their prices. Using VLOOKUP, the spreadsheet finds prices in the list, then calculates the prices for each store using the assigned markup. But we have a N/A error in cells B49 and C49. The VLOOKUP formula is correct, so what's going on? Well, if we look carefully at the name of the nut, \"almond\" has no match in the lookup table, the lookup table uses the plural \"almonds\" instead. So we change almond to almonds, and with that typo fixed, the right prices are filled in. Speaking of typos, sometimes a typo can cause a NAME error. A NAME error can happen when a formula's name isn't recognized or understood. Suppose we see a NAME error in the nut prices spreadsheet. If we look carefully, the VLOOKUP function in cell B21 is spelled incorrectly, it has one extra O; this causes a NAME error for both the price and the resulting markup calculation for the store. To fix this error, we can delete the extra O in VLOOKUP.\nPerfect. Sometimes an error is caused by inconsistent or wrong data. For instance, the NUM error tells us that a formula's calculation can't be performed as specified by the data. The data doesn't make sense for that calculation. Here's what I mean. Suppose we're working on a large construction project using a spreadsheet to track how many months it takes to reach key milestones. We can use the DATEDIF function to calculate the number of months between start and end dates. The function requires the start date to be in the first cell referenced and the end date to be in the second cell referenced. In our case, cells B2 and C2 respectively. The M represents months, as we want this spreadsheet to calculate the number of months between our start and end dates. But we get a NUM error in cell D6. We notice that the end date comes before the start date, so the DATEDIF function can't calculate the number of months between. It's likely the start and end dates were interchanged by accident. We can request verification of the data to make sure. In the meantime, let's reverse the order of the cells in the formula to temporarily get around the error. Now, the result is nine months. What if the client's name was accidentally inserted into the start date in the spreadsheet? You guessed it, we get an error. The VALUE error can indicate a problem with a formula or referenced cells. It's often not clear right away what the problem is, so this error might take a little more effort to fix. In this case, John Welty was input as the start date, making the calculation impossible for the DATEDIF function in the cell D6. We just replace the text, John Welty, with the correct start date of September 1st, 2016.\nLast is the REF error, which often comes up when cells being referenced in a formula have been deleted, thus making the formula unable to perform the calculation. Here's a spreadsheet used to calculate the number of seats available for a company lunch. Let's say the company decided not to run the second floor, so we delete row 4. This results in a REF error when calculating the total seats available in cell B5. To fix this, we can change the formula to add the values in cells B2 and B3. Also, in this case, we could have prevented the REF error by using the SUM function and a range of cells instead of adding the cell value by direct reference. Now, if we delete row 10, the SUM function calculates the total seats available. There you go. We've now fixed some of the most common spreadsheet errors. When you see them again, you'll know what they mean. Troubleshooting is a big part of data analysis, so being able to find solutions is a key skill for data analysts.\n\nFunctions 101\nFormulas are a great way to become more efficient when using spreadsheets, especially when you add shortcuts like copying and pasting, into the mix. As you progress as a data analyst, you'll most likely learn more shortcuts to help your process. But now it's time to move on to functions. While they're closely related to formulas, they're not exactly the same. By the end of this video, you'll understand the difference and know when to use them both. In the world of spreadsheets a function is a preset command that automatically performs a specific process or task using the data. You might remember some of the shortcuts we learned that can be used with formulas. Think of functions as the most useful of the shortcuts. The good news is a lot of spreadsheet functions have names that tell you what they do. There are tons of functions out there. As you continue to work with spreadsheets, you'll find that you use certain ones a lot, and others, rarely or not at all. For now, let's take a look at some of the functions that we can apply to our sales data from the previous video. We'll start with total sales. Let's use the SUM function for this in cell F2. The first steps are pretty similar to what we did in the last video. First, we'll select the cell where we want the calculation to appear. Type equals, then add the word SUM as our function. One of the great things about functions is they don't always need operators, like a plus sign for addition. In this case, after the open parentheses, you can go ahead and select the range of cells you're adding. A colon between the cell references shows that you're using a range. In this case, the range includes cells from the same row. After the closed parentheses, we press Enter. Just like that, our total sales number appears. Just like the formula we used before, functions can be copied and pasted into other cells in the same column.\nBut let's undo that step so that you can see another way to copy a function or formula. Spreadsheets have something called a fill handle. It's a little box that appears in the lower right-hand corner when you click on a cell. If you rest your cursor on the box, you can then drag the fill handle to the other boxes in the same row or column. Any formula or function in that cell will automatically be added to the cells you fill plus, the fill handle will update the formula so the cell references match the row of the columns of the cells you fill.\nThis means the formula is calculated based on the data in each separate row or column. Filling won't work for every situation, but it's still a pretty great trick. Now let's find the average sale for each month using the AVERAGE function.\nDifferent functions perform different calculations, but they work in the same way. Keep in mind, not every calculation you'll come across has its own function to help you. For example, to find the percent change in sales between June and July, you'd use the same formula you used in an earlier video.\nLet's say you're asked to find the lowest monthly sales in this data set. There's a function for that. It's called the MIN function, which stands for minimum. Here's how it works. Say you need to find the lowest monthly sales for the whole set.\nAll you have to do is set up the function. Then after the open parenthesis, select the values from all three rows.\nThis might be important information for your stake holders. Let's add color to the cell with that value, in your data set to make it stand out. In this case, click on cell D2 and then fill color icon, which looks like a paint can, then choose a color. I'll use yellow here. You can follow the same steps for the highest sales by using the, wait for it, MAX function.\nLooks like we have an error message. What could be wrong? We forgot to include an open parentheses after the function. No worries, it's a quick fix.\nBut this is a good reminder to continually check the format of your functions and formulas as you use them. We'll learn more about Error messages and how to work with them later. That's better. Now we'll add color to the cell with the highest sales too.\nThis is just one way to highlight key data. You'll find out about some others later. You've now had a peek at some ways you can add and organize data in a spreadsheet. You've also seen how powerful formulas and functions can be when applied to real world data. As a data analyst, this is just the beginning of your experience with spreadsheets. You'll soon find out how much more spreadsheets have to offer. In the meantime, you're free to practice some of these formulas, functions, and other processes on your own. It can be fun to experiment, and see all that spreadsheets can do. Soon, you will switch from spreadsheets to structured thinking. The data analytics pieces are starting to fit together. Exciting stuff is coming right up. So stick around.\n\nBefore solving a problem, understand it\nAlbert Einstein once said,\" If I were given one hour to save the planet, I would spend 59 minutes defining the problem and one minute resolving it.\" Now, that might seem extreme, but it does show us just how important it is to define the problems before trying to solve them. A lot of times, teams jump right into data analysis before realizing a few months later that they are either solving the wrong problem or they don't have the right data. In this video, we will learn how to develop a structured approach to defining the problem domain. This is important because if you define the problem clearly from the start, it'll be easier to solve, which saves a lot of time, money, and resources. In the data world, we call this first piece the problem domain: the specific area of analysis that encompasses every activity affecting or affected by the problem. Before we can do anything else, we need to understand the problem domain and all of its parts and relationships so that we can discover the whole story. Actually calling it the first piece makes me think of a jigsaw puzzle. Say you have a puzzle. Let's think of that puzzle as our problem domain. You have all 500 pieces but you lost the box. So you don't know what image the puzzle will reveal. Will it be an animal? A waterfall? A bowl of oranges? Whatever it is, it's going to be tough trying to put it together without an image you can refer to. Even the greatest puzzler in the galaxy would need a new process and lots of time to complete that puzzle. Data analysts face the same kinds of challenges too. You might remember that data analysts aren't always given the complete picture at the start of a project. A big part of their job is to develop a structured approach and use critical thinking to find the best solution. That starts with understanding the problem domain. This is where structured thinking comes into play. To successfully solve a problem as a data analyst, you need to train your brain to think structurally. That's exactly what you'll learn coming up. See you there.\n\nScope of work and structured thinking\nEarlier I told you that carefully defining a business problem can ultimately save time, money, and resources. All of this is achieved through structured thinking. Structured thinking is the process of recognizing the current problem or situation, organizing available information, revealing gaps and opportunities, and identifying the options. In other words, it's a way of being super prepared. It's having a clear list of what you are expected to deliver, a timeline for major tasks and activities, and checkpoints so the team knows you're making progress. In this video, we'll look at how structured thinking helps us save time and effort, but also makes our job as data analysts easier because it allows us to better understand the work we are doing. In the business world, it's common for teams to spend hours of valuable time trying to solve an important problem, only to end up back where they started. Not only is the initial problem not resolved, but they've spent hours not resolving it. This outcome negatively affects you, your team, and the organization as a whole. But it can usually be prevented. Many times the situation is a result of not fully understanding the issue. Structured thinking will help you understand problems at a high level so that you can identify areas that need deeper investigation and understanding. The starting place for structured thinking is the problem domain, which you might have remembered from earlier. Once you know the specific area of analysis, you can set your base and lay out all your requirements and hypotheses before you start investigating. With a solid base in place, you'll be ready to deal with any obstacles that come up. What kind of obstacles? Well, let's say you're asked to predict the future value of an apartment building based on a given dataset. You have hundreds of variables and every one is crucial to your analysis. But what if one variable accidentally gets left out, like square footage, for example? You'd have to go back and redo all your hard work. That's because missing variables can lead to inaccurate conclusions. Another way that you can practice structured thinking and avoid mistakes is by using a scope of work. A scope of work or SOW is an agreed- upon outline of the work you're going to perform on a project. For many businesses, this includes things like work details, schedules, and reports that the client can expect. Now, as a data analyst, your scope of work will be a bit more technical and include those basic items we just mentioned, but you'll also focus on things like data preparation, validation, analysis of quantitative and qualitative datasets, initial results, and maybe even some visuals to really get the point across. Let's bring a scope of work to life with a simple example. Say a couple has hired a wedding planner. We'll focus on just one task, the wedding invitations. Here's what might be in scope of work: deliverables, timeline, milestones, and reports. Let's break down just one of these, deliverables. The wedding planner and couple will need to decide on the invitation, make a list of people to invite, collect their addresses, print the invitations, address the envelopes, stamp them, and mail them out. Now let's check out the timelines. You'll notice the dates and the milestones which keep us on track. Finally, we have the reports, which give our couple some peace of mind by telling them when each step is complete. A scope of work can be a simple but powerful tool. With a solid scope of work, you'll be able to address any confusion, contradictions, or questions about the data up- front and make sure these sneaky setbacks don't stand in your way. This is a simple example of what a scope of work might look like. But later, you'll be able to practice building your own. Next up in our scope, we'll check out setbacks from a different angle by learning the importance of contextualizing data and avoiding bias. Looking forward to sharing some cool insights with you.\n\nStaying objective\nWelcome back. In this video, we'll explore the importance of contextualizing data, and recognizing data bias. Let's get started. Data doesn't live in a vacuum, it needs context. Earlier, we learnt that context is the condition in which something exists or happens. Actions can be appropriate in some context, but inappropriate in others, for example, yelling move, is rude one context, if your friend is standing in front of the TV, but it's entirely appropriate in another, if that friend is about to get hit by a kid on a tricycle. Do you see the difference? In the world of data, numbers don't mean much without context. I'll let my fellow Googler Ed, tell you a little bit more about that As we have more and more data available to us. We can leverage that data in increasingly sophisticated ways, and generate more powerful insights from it. We use data at many different levels. Sometimes our data is descriptive, answering questions like, how much did we spend on travel last month? Data becomes more valuable, as we generate diagnostic and predictive insights, like understanding why travel spend increased last month. Data is most valuable, however, when we can generate prescriptive insights. For example, how can we leverage data to incentivize more efficient travel? Figuring out what data means, is just as important as collecting it. As a data analyst, a big part of your job, is putting data into context. It's also up to you, to remain objective and recognize all sides of an argument, before drawing conclusions. The thing about context, is that it's very personal. If two people curate the same data set, and follow the same directions, there's a chance they will end up with different results. Why? Because there is no universal set of contextual interpretations. Everyone approaches it in their own way. Even if the data collection process is correct, the analysis can still be misinterpreted. Conclusions can be influenced by your own conscious and subconscious biases, which are based on cultural, social and market norms. For example, if you ask a Boston resident, which baseball team is the best, chances are, they're going to say Boston Red Sox. Which brings us to a major limitation of data analytics. If the analysis is not objective, the conclusions can be misleading. To really understand what the data is about, you have to think through who, what, where, when, how and why. It's good to ask yourself questions like, who collected the data? And what is it about? What does the data represent in the world, and how does it relate to other data? When, was the data collected? Data collected awhile ago may have certain limitations, given the present day situation. For example, if we collected phone numbers over the past century, at some point, mobile phones would have been introduced, leading to the need for an additional phone number field. You should also think about, where, was the data collected? A lot can change across cities, states and countries, and how was it collected. A survey might not be as effective as an in-person interview, for example. Of course, there's the, why. The why can have a particularly strong relationship with bias. Why? Because sometimes, data is collected, or even made up, to serve an agenda. The best thing you can do for the fairness and accuracy of your data, is to make sure you start with an accurate representation of the population, and collect the data in the most appropriate, and objective way. Then, you'll have the facts so you can pass on to your team. Hopefully you now understand the importance of fair and objective data, and how important a context is, when it comes to understanding and interpreting it. Next up, we'll figure out how we can bring it to life.\n", "source": "coursera_d", "evaluation": "exam"}
{"instructions": ["Question 1. When working with a new team, which of the following actions can help you to adapt to different communication expectations? Select all that apply.\nA. Ask questions when you are unsure of something\nB. Learn the team's preferred communication style\nC. Observe how teammates communicate with each other\nD. Ignore the team's communication preferences and use your own style", "Question 2. Focusing on stakeholder expectations enables data analysts to achieve what goals? Select all that apply.\nA. Improve communication among teams\nB. Build trust\nC. Understand project goals\nD. Multitask more effectively", "Question 3. When leading a meeting, which of the following practices can help ensure a productive and successful meeting? Select all that apply.\nA. Arrive early and set up beforehand\nB. Engage with all attendees\nC. Keep the number of people at the meeting under 10, if possible\nD. Dominate the conversation and talk over others", "Question 4. Which of the following actions can help you shift a situation from problematic to productive during a conflict? Select all that apply.\nA. Reframe the problem\nB. Start a conversation\nC. Focus on blaming others\nD. Ask if there are other important things to consider", "Question 5. In a data analysis project, what are some ways to balance speed and accuracy when communicating answers to stakeholders? Select all that apply.\nA. Reframe the question\nB. Understand their needs\nC. Set clear expectations\nD. Provide quick but incomplete answers", "Question 6. What are some ways to ensure that your work answers the right questions and delivers useful results? Select all that apply.\nA. Set clear expectations about the timeframe\nB. Outline the problem\nC. Reframe the question\nD. Provide incomplete data", "Question 7. When working on a project, which of the following questions can help you stay focused on the task? Select all that apply.\nA. Who are the primary and secondary stakeholders?\nB. Who is managing the data?\nC. Where can I go for help?\nD. What are my personal goals unrelated to the project?", "Question 8. When communicating with stakeholders or team members, what are the four key questions data analysts should ask themselves? Select all that apply.\nA. Who is my audience?\nB. What does my audience already know?\nC. What does my audience need to know?\nD. How can I communicate effectively to my audience?", "Question 9. What are some benefits of focusing on stakeholder expectations when working as a data analyst? Select all that apply.\nA. Understand project goals\nB. Improve communication among teams\nC. Build trust\nD. Increase personal job satisfaction", "Question 10. When sharing data with a team, which of the following variables should be considered to ensure the team has all the information needed to make informed, data-driven decisions? Select all that apply.\nA. Process\nB. Outcome\nC. Personal preferences\nD. Office politics", "Question 11. Which of the following steps are key to leading a professional online meeting? Select all that apply.\nA. Maintaining control of the meeting by keeping everyone else on mute.\nB. Sitting in a quiet area that\u2019s free of distractions\nC. Keeping an eye on your inbox during the meeting in case of an important email\nD. Making sure your technology is working properly before starting the meeting", "Question 12.  The customer-facing team does which of the following activities? Select all that apply.\nA. Share customer feedback\nB. Compile information about customer expectations\nC. Tell the data story to others\nD. Provide operational leadership for the company"], "outputs": ["ABC", "ABC", "ABC", "ABD", "ABC", "ABC", "ABC", "ABCD", "ABC", "AB", "BD", "AB"], "input": "Communicating with your team\nHey, welcome back. So far you've learned about things like spreadsheets, analytical thinking skills, metrics, and mathematics. These are all super important technical skills that you'll build on throughout your Data Analytics career. You should also keep in mind that there are some non-technical skills that you can use to create a positive and productive working environment. These skills will help you consider the way you interact with your colleagues as well as your stakeholders. We already know that it's important to keep your team members' and stakeholders' needs in mind. Coming up, we'll talk about why that is. We'll start learning some communication best practices you can use in your day to day work. Remember, communication is key. We'll start by learning all about effective communication, and how to balance team member and stakeholder needs. Think of these skills as new tools that'll help you work with your team to find the best possible solutions. Alright, let's head on to the next video and get started.\n\nBalancing needs and expectations across your team\nAs a data analyst, you'll be required to focus on a lot of different things, And your stakeholders' expectations are one of the most important. We're going to talk about why stakeholder expectations are so important to your work and look at some examples of stakeholder needs on a project. By now you've heard me use the term stakeholder a lot. So let's refresh ourselves on what a stakeholder is. Stakeholders are people that have invested time, interest, and resources into the projects that you'll be working on as a data analyst. In other words, they hold stakes in what you're doing. There's a good chance they'll need the work you do to perform their own needs. That's why it's so important to make sure your work lines up with their needs and why you need to communicate effectively with all of the stakeholders across your team. Your stakeholders will want to discuss things like the project objective, what you need to reach that goal, and any challenges or concerns you have. This is a good thing. These conversations help build trust and confidence in your work. Here's an example of a project with multiple team members. Let's explore what they might need from you at different levels to reach the project's goal. Imagine you're a data analyst working with a company's human resources department. The company has experienced an increase in its turnover rate, which is the rate at which employees leave a company. The company's HR department wants to know why that is and they want you to help them figure out potential solutions. The Vice President of HR at this company is interested in identifying any shared patterns across employees who quit and seeing if there's a connection to employee productivity and engagement. As a data analyst, it's your job to focus on the HR department's question and help find them an answer. But the VP might be too busy to manage day-to-day tasks or might not be your direct contact. For this task, you'll be updating the project manager more regularly. Project managers are in charge of planning and executing a project. Part of the project manager's job is keeping the project on track and overseeing the progress of the entire team. In most cases, you'll need to give them regular updates, let them know what you need to succeed and tell them if you have any problems along the way. You might also be working with other team members. For example, HR administrators will need to know the metrics you're using so that they can design ways to effectively gather employee data. You might even be working with other data analysts who are covering different aspects of the data. It's so important that you know who the stakeholders and other team members are in a project so that you can communicate with them effectively and give them what they need to move forward in their own roles on the project. You're all working together to give the company vital insights into this problem. Back to our example. By analyzing company data, you see a decrease in employee engagement and performance after their first 13 months at the company, which could mean that employees started feeling demotivated or disconnected from their work and then often quit a few months later. Another analyst who focuses on hiring data also shares that the company had a large increase in hiring around 18 months ago. You communicate this information with all your team members and stakeholders and they provide feedback on how to share this information with your VP. In the end, your VP decides to implement an in-depth manager check-in with employees who are about to hit their 12 month mark at the firm to identify career growth opportunities, which reduces the employee turnover starting at the 13 month mark. This is just one example of how you might balance needs and expectations across your team. You'll find that in pretty much every project you work on as a data analyst, different people on your team, from the VP of HR to your fellow data analysts, will need all your focus and communication to carry the project to success. Focusing on stakeholder expectations will help you understand the goal of a project, communicate more effectively across your team, and build trust in your work. Coming up, we'll discuss how to figure out where you fit on your team and how you can help move a project forward with focus and determination.\n\nFocus on what matters\nSo now that we know the importance of finding the balance across your stakeholders and your team members. I want to talk about the importance of staying focused on the objective. This can be tricky when you find yourself working with a lot of people with competing needs and opinions. But by asking yourself a few simple questions at the beginning of each task, you can ensure that you're able to stay focused on your objective while still balancing stakeholder needs. Let's think about our employee turnover example from the last video. There, we were dealing with a lot of different team members and stakeholders like managers, administrators, even other analysts. As a data analyst, you'll find that balancing everyone's needs can be a little chaotic sometimes but part of your job is to look past the clutter and stay focused on the objective. It's important to concentrate on what matters and not get distracted. As a data analyst, you could be working on multiple projects with lots of different people but no matter what project you're working on, there are three things you can focus on that will help you stay on task. One, who are the primary and secondary stakeholders? Two who is managing the data? And three where can you go for help? Let's see if we can apply those questions to our example project. The first question you can ask is about who those stakeholders are. The primary stakeholder of this project is probably the Vice President of HR who's hoping to use his project's findings to make new decisions about company policy. You'd also be giving updates to your project manager, team members, or other data analysts who are depending on your work for their own task. These are your secondary stakeholders. Take time at the beginning of every project to identify your stakeholders and their goals. Then see who else is on your team and what their roles are. Next, you'll want to ask who's managing the data? For example, think about working with other analysts on this project. You're all data analysts, but you may manage different data within your project. In our example, there was another data analyst who was focused on managing the company's hiring data. Their insights around a surge of new hires 18 months ago turned out to be a key part of your analysis. If you hadn't communicated with this person, you might have spent a lot of time trying to collect or analyze hiring data yourself or you may not have even been able to include it in your analysis at all. Instead, you were able to communicate your objectives with another data analyst and use existing work to make your analysis richer. By understanding who's managing the data, you can spend your time more productively. Next step, you need to know where you can go when you need help. This is something you should know at the beginning of any project you work on. If you run into bumps in the road on your way to completing a task, you need someone who is best positioned to take down those barriers for you. When you know who's able to help, you'll spend less time worrying about other aspects of the project and more time focused on the objective. So who could you go to if you ran into a problem on this project? Project managers support you and your work by managing the project timeline, providing guidance and resources, and setting up efficient workflows. They have a big picture view of the project because they know what you and the rest of the team are doing. This makes them a great resource if you run into a problem in the employee turnover example, you would need to be able to access employee departure survey data to include in your analysis. If you're having trouble getting approvals for that access, you can speak with your project manager to remove those barriers for you so that you can move forward with your project. Your team depends on you to stay focused on your task so that as a team, you can find solutions. By asking yourself three easy questions at the beginning of new projects, you'll be able to address stakeholder needs, feel confident about who is managing the data, and get help when you need it so that you can keep your eyes on the prize: the project objective. So far we've covered the importance of working effectively on a team while maintaining your focus on stakeholder needs. Coming up, we'll go over some practical ways to become better communicators so that we can help make sure the team reaches its goals.\n\nClear communication is key \nWelcome back. We've talked a lot about understanding your stakeholders and your team so that you can balance their needs and maintain a clear focus on your project objectives. A big part of that is building good relationships with the people you're working with. How do you do that? Two words: clear communication. Now we're going to learn about the importance of clear communication with your stakeholders and team members. Start thinking about who you want to communicate with and when. First, it might help to think about communication challenges you might already experience in your daily life. Have you ever been in the middle of telling a really funny joke only to find out your friend already knows the punchline? Or maybe they just didn't get what was funny about it? This happens all the time, especially if you don't know your audience. This kind of thing can happen at the workplace too. Here's the secret to effective communication. Before you put together a presentation, send an e-mail, or even tell that hilarious joke to your co-worker, think about who your audience is, what they already know, what they need to know and how you can communicate that effectively to them. When you start by thinking about your audience, they'll know it and appreciate the time you took to consider them and their needs. Let's say you're working on a big project, analyzing annual sales data, and you discover that all of the online sales data is missing. This could affect your whole team and significantly delay the project. By thinking through these four questions, you can map out the best way to communicate across your team about this problem. First, you'll need to think about who your audience is. In this case, you'll want to connect with other data analysts working on the project, as well as your project manager and eventually the VP of sales, who is your stakeholder. Next up, you'll think through what this group already knows. The other data analysts working on this project know all the details about which data-set you are using already, and your project manager knows the timeline you're working towards. Finally, the VP of sales knows the high-level goals of the project. Then you'll ask yourself what they need to know to move forward. Your fellow data analysts need to know the details of where you have tried so far and any potential solutions you've come up with. Your project manager would need to know the different teams that could be affected and the implications for the project, especially if this problem changes the timeline. Finally, the VP of sales will need to know that there is a potential issue that would delay or affect the project. Now that you've decided who needs to know what, you can choose the best way to communicate with them. Instead of a long, worried e-mail which could lead to lots back and forth, you decide to quickly book in a meeting with your project manager and fellow analysts. In the meeting, you let the team know about the missing online sales data and give them more background info. Together, you discuss how this impacts other parts of the project. As a team, you come up with a plan and update the project timeline if needed. In this case, the VP of sales didn't need to be invited to your meeting, but would appreciate an e-mail update if there were changes to the timeline which your project manager might send along herself. When you communicate thoughtfully and think about your audience first, you'll build better relationships and trust with your team members and stakeholders. That's important because those relationships are key to the project's success and your own too. When you're getting ready to send an e-mail, organize some meeting, or put together a presentation, think about who your audience is, what they already know, what they need to know and how you can communicate that effectively to them. Next up, we'll talk more about communicating at work and you'll learn some useful tips to make sure you get your message across clearly.\n\nTips for effective communication\nNo matter where you work, you'll probably need to communicate with other people as part of your day to day. Every organization and every team in that organization will have different expectations for communication. Coming up, We'll learn some practical ways to help you adapt to those different expectations and some things that you can carry over from team to team. Let's get started. When you started a new job or a new project, you might find yourself feeling a little out of sync with the rest of your team and how they communicate. That's totally normal. You'll figure things out in no time. if you're willing to learn as you go and ask questions when you aren't sure of something. For example, if you find your team uses acronyms you aren't familiar with, don't be afraid to ask what they mean. When I first started at google, I had no idea what L G T M meant and I was always seeing it in comment threads. Well, I learned it stands for looks good to me and I use it all the time now if I need to give someone my quick feedback, that was one of the many acronyms I've learned and I come across new ones all the time and I'm never afraid to ask. Every work setting has some form of etiquette. Maybe your team members appreciate eye contact and a firm handshake. Or it might be more polite to bow, especially if you find yourself working with international clients. You might also discover some specific etiquette rules just by watching your coworkers communicate. And it won't just be in person communication you'll deal with. Almost 300 billion emails are sent and received every day and that number is only growing. Fortunately there are useful skills you can learn from those digital communications too. You'll want your emails to be just as professional as your in-person communications. Here are some things that can help you do that. Good writing practices will go a long way to make your emails professional and easy to understand. Emails are naturally more formal than texts, but that doesn't mean that you have to write the next great novel. Just taking the time to write complete sentences that have proper spelling and punctuation will make it clear you took time and consideration in your writing. Emails often get forwarded to other people to read. So write clearly enough that anyone could understand you. I like to read important emails out loud before I hit send; that way, I can hear if they make sense and catch any typos. And keep in mind the tone of your emails can change over time. If you find that your team is fairly casual, that's great. Once you get to know them better, you can start being more casual too, but being professional is always a good place to start. A good rule of thumb: Would you be proud of what you had written if it were published on the front page of a newspaper? If not revise it until you are. You also don't want your emails to be too long. Think about what your team member needs to know and get to the point instead of overwhelming them with a wall of text. You'll want to make sure that your emails are clear and concise so they don't get lost in the shuffle. Let's take a quick look at two emails so that you can see what I mean.\nHere's the first email. There's so much written here that it's kind of hard to see where the important information is. And this first paragraph doesn't give me a quick summary of the important takeaways. It's pretty casual to the greeting is just, \"Hey,\" and there's no sign off. Plus I can already spot some typos. Now let's take a look at the second email. Already, it's less overwhelming, right? Just a few sentences, telling me what I need to know. It's clearly organized and there's a polite greeting and sign off. This is a good example of an email; short and to the point, polite and well-written. All of the things we've been talking about so far. But what do you do if, what you need to say is too long for an email? Well, you might want to set up a meeting instead. It's important to answer in a timely manner as well. You don't want to take so long replying to emails that your coworkers start wondering if you're okay. I always try to answer emails in 24-48 hours. Even if it's just to give them a timeline for when I'll have the actual answers they're looking for. That way, I can set expectations and they know I'm working on it. That works the other way around too. If you need a response on something specific from one of your team members, be clear about what you need and when you need it so that they can get back to you. I'll even include a date in my subject line and bold dates in the body of my email, so it's really clear. Remember, being clear about your needs is a big part of being a good communicator. We covered some great ways to improve our professional communication skills, like asking questions, practicing good writing habits and some email tips and tricks. These will help you communicate clearly and effectively with your team members on any project. It might take some time, but you'll find a communication style that works for you and your team, both in person and online. As long as you're willing to learn, you won't have any problems adapting to the different communication expectations you'll see in future jobs.\n\nBalancing expectations and realistic project goals\nWe discussed before how data has limitations. Sometimes you don't have access to the data you need, or your data sources aren't aligned or your data is unclean. This can definitely be a problem when you're analyzing data, but it can also affect your communication with your stakeholders. That's why it's important to balance your stakeholders' expectations with what is actually possible for a project. We're going to learn about the importance of setting realistic, objective goals and how to best communicate with your stakeholders about problems you might run into. Keep in mind that a lot of things depend on your analysis. Maybe your team can't make a decision without your report. Or maybe your initial data work will determine how and where additional data will be gathered. You might remember that we've talked about some situations where it's important to loop stakeholders in. For example, telling your project manager if you're on schedule or if you're having a problem. Now, let's look at a real-life example where you need to communicate with stakeholders and what you might do if you run into a problem. Let's say you're working on a project for an insurance company. The company wants to identify common causes of minor car accidents so that they can develop educational materials that encourage safer driving. There's a few early questions you and your team need to answer. What driving habits will you include in your dataset? How will you gather this data? How long will it take you to collect and clean that data before you can use it in your analysis? Right away you want to communicate clearly with your stakeholders to answer these questions, so you and your team can set a reasonable and realistic timeline for the project. It can be tempting to tell your stakeholders that you'll have this done in no time, no problem. But setting expectations for a realistic timeline will help you in the long run. Your stakeholders will know what to expect when, and you won't be overworking yourself and missing deadlines because you overpromised. I find that setting expectations early helps me spend my time more productively. So as you're getting started, you'll want to send a high-level schedule with different phases of the project and their approximate start dates. In this case, you and your teams establish that you'll need three weeks to complete analysis and provide recommendations, and you let your stakeholders know so they can plan accordingly. Now let's imagine you're further along in the project and you run into a problem. Maybe drivers have opted into sharing data about their phone usage in the car, but you discover that some sources count GPS usage, and some don't in their data. This might add time to your data processing and cleaning and delay some project milestones. You'll want to let your project manager know and maybe work out a new timeline to present to stakeholders. The earlier you can flag these problems, the better. That way your stakeholders can make necessary changes as soon as possible. Or what if your stakeholders want to add car model or age as possible variables. You'll have to communicate with them about how that might change the model you've built, if it can be added and before the deadlines, and any other obstacles that they need to know so they can decide if it's worth changing at this stage of the project. To help them you might prepare a report on how their request changes the project timeline or alters the model. You could also outline the pros and cons of that change. You want to help your stakeholders achieve their goals, but it's important to set realistic expectations at every stage of the project. This takes some balance. You've learned about balancing the needs of your team members and stakeholders, but you also need to balance stakeholder expectations and what's possible with the projects, resources, and limitations. That's why it's important to be realistic and objective and communicate clearly. This will help stakeholders understand the timeline and have confidence in your ability to achieve those goals. So we know communication is key and we have some good rules to follow for our professional communication. Coming up we'll talk even more about answering stakeholder questions, delivering data and communicating with your team.\n\nSarah: How to communicate with stakeholders\nI'm Sarah and I'm a senior analytical leader at Google. As a data analyst, there's going to be times where you have different stakeholders who have no idea about the amount of time that it takes you to do each project, and in the very beginning when I'm asked to do a project or to look into something, I always try to give a little bit of expectation settings on the turn around because most of your stakeholders don't really understand what you do with data and how you get it and how you clean it and put together the story behind it. The other thing that I want to make clear to everyone is that you have to make sure that the data tells you the stories. Sometimes people think that data can answer everything and sometimes we have to acknowledge that that is simply untrue. I recently worked with a state to figure out why people weren't signing up for the benefits that they needed and deserved. We saw people coming to the site and where they would sign up for those benefits and see if they're qualified. But for some reason there was something stopping them from taking the step of actually signing up. So I was able to look into it using Google Analytics to try to uncover what is stopping people from taking the action of signing up for these benefits that they need and deserve. And so I go into Google Analytics, I see people are going back between this service page and the unemployment page back to the service page, back to the unemployment page. And so I came up with a theory that hey, people aren't finding the information that they need in order to take the next step to see if they qualify for these services. The only way that I can actually know why someone left the site without taking action is if I ask them. I would have to survey them. Google Analytics did not give me the data that I would need to 100% back my theory or deny it. So when you're explaining to your stakeholders, \"Hey I have a theory. This data is telling me a story. However I can't 100% know due to the limitations of data,\" You just have to say it. So the way that I communicate that is I say \"I have a theory that people are not finding the information that they need in order to take action. Here's the proved points that I have that support that theory.\" So what we did was we then made it a little bit easier to find that information. Even though we weren't 100% sure that my theory was correct, we were confident enough to take action and then we looked back, and we saw all the metrics that pointed me to this theory improve. And so that always feels really good when you're able to help a cause that you believe in do better, and help more people through data. It makes all the nerdy learning about SQL and everything completely worth it.\n\nThe data tradeoff: Speed versus accuracy\nWe live in a world that loves instant gratification, whether it's overnight delivery or on-demand movies. We want what we want and we want it now. But in the data world, speed can sometimes be the enemy of accuracy, especially when collaboration is required. We're going to talk about how to balance speedy answers with right ones and how to best address these issues by re-framing questions and outlining problems. That way your team members and stakeholders understand what answers they can expect when. As data analysts, we need to know the why behind things like a sales slump, a player's batting average, or rainfall totals. It's not just about the figures, it's about the context too and getting to the bottom of these things takes time. So if a stakeholder comes knocking on your door, a lot of times that person may not really know what they need. They just know they want it at light speed. But sometimes the pressure gets to us and even the most experienced data analysts can be tempted to cut corners and provide flawed or unfinished data in the interest of time. When that happens, so much of the story in the data gets lost. That's why communication is one of the most valuable tools for working with teams. It's important to start with structured thinking and a well-planned scope of work, which we talked about earlier. If you start with a clear understanding of your stakeholders' expectations, you can then develop a realistic scope of work that outlines agreed upon expectations, timelines, milestones, and reports. This way, your team always has a road map to guide their actions. If you're pressured for something that's outside of the scope, you can feel confidence setting more realistic expectations. At the end of the day, it's your job to balance fast answers with the right answers. Not to mention figuring out what the person is really asking. Now seems like a good time for an example. Imagine your VP of HR shows up at your desk demanding to see how many new hires are completing a training course they've introduced. She says, \"There's no way people are going through each section of the course. The human resources team is getting slammed with questions. We should probably just cancel the program.\" How would you respond? Well, you could log into the system, crunch some numbers, and hand them to your supervisor. That would take no time at all. But the quick answer might not be the most accurate one. So instead, you could re-frame her question, outline the problem, challenges, potential solutions, and time-frame. You might say, \"I can certainly check out the rates of completion, but I sense there may be more to the story here. Could you give me two days to run some reports and learn what's really going on?\" With more time, you can gain context. You and the VP of HR decide to expand the project timeline, so you can spend time gathering anonymous survey data from new employees about the training course. Their answers provide data that can help you pinpoint exactly why completion rates are so low. Employees are reporting that the course feels confusing and outdated. Because you were able to take time to address the bigger problem, the VP of HR has a better idea about why new employees aren't completing the course and can make new decisions about how to update it. Now the training course is easy to follow and the HR department isn't getting as many questions. Everybody benefits. Redirecting the conversation will help you find the real problem which leads to more insightful and accurate solutions. But it's important to keep in mind, sometimes you need to be the bearer of bad news and that's okay. Communicating about problems, potential solutions and different expectations can help you move forward on a project instead of getting stuck. When it comes to communicating answers with your teams and stakeholders, the fastest answer and the most accurate answer aren't usually the same answer. But by making sure that you understand their needs and setting expectations clearly, you can balance speed and accuracy. Just make sure to be clear and upfront and you'll find success.\n\nThink about your process and outcome\nData has the power to change the world. Think about this. A bank identifies 15 new opportunities to promote a product, resulting in $120 million in revenue. A distribution company figures out a better way to manage shipping, reducing their cost by $500,000. Google creates a new tool that can identify breast cancer tumors in nearby lymph nodes. These are all amazing achievements, but do you know what they have in common? They're all the results of data analytics. You absolutely have the power to change the world as a data analyst. And it starts with how you share data with your team. In this video, we will think through all of the variables you should consider when sharing data. When you successfully deliver data to your team, you can ensure that they're able to make the best possible decisions. Earlier we learned that speed can sometimes affect accuracy when sharing database information with a team. That's why you need a solid process that weighs the outcomes and actions of your analysis. So where do you start? Well, the best solutions start with questions. You might remember from our last video, that stakeholders will have a lot of questions but it's up to you to figure out what they really need. So ask yourself, does your analysis answer the original question?\nAre there other angles you haven't considered? Can you answer any questions that may get asked about your data and analysis? That last question brings up something else to think about. How detailed should you be when sharing your results?\nWould a high level analysis be okay?\nAbove all else, your data analysis should help your team make better, more informed decisions. Here is another example: Imagine a landscaping company is facing rising costs and they can't stay competitive in the bidding process. One question you could ask to solve this problem is, can the company find new suppliers without compromising quality? If you gave them a high-level analysis, you'd probably just include the number of clients and cost of supplies.\nHere your stakeholder might object. She's worried that reducing quality will limit the company's ability to stay competitive and keep customers happy. Well, she's got a point. In that case, you need to provide a more detailed data analysis to change her mind. This might mean exploring how customers feel about different brands. You might learn that customers don't have a preference for specific landscape brands. So the company can change to the more affordable suppliers without compromising quality.\nIf you feel comfortable using the data to answer all these questions and considerations, you've probably landed on a solid conclusion. Nice! Now that you understand some of the variables involved with sharing data with a team, like process and outcome, you're one step closer to making sure that your team has all the information they need to make informed, data-driven decisions.\n\nMeeting best practices\nNow it's time to discuss meetings. Meetings are a huge part of how you communicate with team members and stakeholders. Let's cover some easy-to-follow do's and don'ts, you can use for meetings both in person or online so that you can use these communication best practices in the future. At their core, meetings make it possible for you and your team members or stakeholders to discuss how a project is going. But they can be so much more than that. Whether they're virtual or in person, team meetings can build trust and team spirit. They give you a chance to connect with the people you're working with beyond emails. Another benefit is that knowing who you're working with can give you a better perspective of where your work fits into the larger project. Regular meetings also make it easier to coordinate team goals, which makes it easier to reach your objectives. With everyone on the same page, your team will be in the best position to help each other when you run into problems too. Whether you're leading a meeting or just attending it, there are best practices you can follow to make sure your meetings are a success. There are some really simple things you can do to make a great meeting. Come prepared, be on time, pay attention, and ask questions. This applies to both meetings you lead and ones you attend. Let's break down how you can follow these to-dos for every meeting. What do I mean when I say come prepared? Well, a few things. First, bring what you need. If you like to take notes, have your notebook and pens in your bag or your work device on hand. Being prepared also means you should read the meeting agenda ahead of time and be ready to provide any updates on your work. If you're leading the meeting, make sure to prepare your notes and presentations and know what you're going to talk about and of course, be ready to answer questions. These are some other tips that I like to follow when I'm leading a meeting. First, every meeting should focus on making a clear decision and include the person needed to make that decision. And if there needs to be a meeting in order to make a decision, schedule it immediately. Don't let progress stall by waiting until next week's meeting. Lastly, try to keep the number of people at your meeting under 10 if possible. More people makes it hard to have a collaborative discussion. It's also important to respect your team members' time. The best way to do this is to come to meetings on time. If you're leading the meeting, show up early and set up beforehand so you're ready to start when people arrive. You can do the same thing for online meetings. Try to make sure your technology is working beforehand and that you're watching the clock so you don't miss a meeting accidentally. Staying focused and attentive during a meeting is another great way to respect your team members' time. You don't want to miss something important because you were distracted by something else during a presentation. Paying attention also means asking questions when you need clarification, or if you think there may be a problem with a project plan. Don't be afraid to reach out after a meeting. If you didn't get to ask your question, follow up with the group afterwards and get your answer. When you're the person leading the meeting, make sure you build and send out an agenda beforehand, so your team members can come prepared and leave with clear takeaways. You'll also want to keep everyone involved. Try to engage with all your attendees so you don't miss out on any insights from your team members. Let everyone know that you're open to questions after the meeting too. It's a great idea to take notes even when you're leading the meeting. This makes it easier to remember all questions that were asked. Then afterwards you can follow up with individual team members to answer those questions or send an update to your whole team depending on who needs that information. Now let's go over what not to do in meetings. There are some obvious \"don'ts\" here. You don't want to show up unprepared, late, or distracted for meetings. You also don't want to dominate the conversation, talk over others, or distract people with unfocused discussion. Try to make sure you give other team members a chance to talk and always let them finish their thought before you start speaking. Everyone who is attending your meeting should be giving their input. Provide opportunities for people to speak up, ask questions, call for expertise, and solicit their feedback. You don't want to miss out on their valuable insights. And try to have everyone put their phones or computers on silent when they're not speaking, you included. Now we've learned some best practices you can follow in meetings like come prepared, be on time, pay attention, and ask questions. We also talked about using meetings productively to make clear decisions and promoting collaborative discussions and to reach out after a meeting to address questions you or others might have had. You also know what not to do in meetings: showing up unprepared, late, or distracted, or talking over others and missing out on their input. With these tips in mind, you'll be well on your way to productive, positive team meetings. But of course, sometimes there will be conflict in your team. We'll discuss conflict resolution soon.\n\nXimena: Joining a new team\nJoining a new team was definitely scary at the beginning. Especially at a company like Google where it's really big and everyone is extremely smart. But I really leaned on my manager to understand what I could bring to the table. And that made me feel a lot more comfortable in meetings while sharing my abilities. I found that my best projects start off when the communication is really clear about what's expected. If I leave the meeting where the project has been asked of me knowing exactly where to start and what I need to do, that allows for me to get it done faster, more efficiently, and getting to the real goal of it and maybe going an extra step further because I didn't have to spend any time confused on what I needed to be doing. Communication is so important because it gets you to the finish line the most efficiently and also makes you look really good. When I first started I had a good amount of projects thrown at me and I was really excited. So, I went into them without asking too many questions. At first that was an obstacle, because while you can thrive in ambiguity, ambiguity as to what the project objective is, can be really harmful when you're actually trying to get the goal done. And I overcame that by simply taking a step back when someone asks me to do the project and just clarifying what that goal was. Once that goal was crisp, I was happy to go into the ambiguity of how to get there, but the goal has to be really objective and clear. I'm Ximena and I'm a Financial Analyst.\n\nFrom conflict to collaboration\nIt's normal for conflict to come up in your work life. A lot of what you've learned so far, like managing expectations and communicating effectively can help you avoid conflict, but sometimes you'll run into conflict anyways. If that happens, there are ways to resolve it and move forward. In this video, we will talk about how conflict could happen and the best ways you can practice conflict resolution. A conflict can pop up for a variety of reasons. Maybe a stakeholder misunderstood the possible outcomes for your project; maybe you and your team member have very different work styles; or maybe an important deadline is approaching and people are on edge. Mismatched expectations and miscommunications are some of the most common reasons conflicts happen. Maybe you weren't clear on who was supposed to clean a dataset and nobody cleaned it, delaying a project. Or maybe a teammate sent out an email with all of your insights included, but didn't mention it was your work. While it can be easy to take conflict personally, it's important to try and be objective and stay focused on the team's goals. Believe it or not, tense moments can actually be opportunities to re-evaluate a project and maybe even improve things. So when a problem comes up, there are a few ways you can flip the situation to be more productive and collaborative. One of the best ways you can shift a situation from problematic to productive is to just re-frame the problem. Instead of focusing on what went wrong or who to blame, change the question you're starting with. Try asking, how can I help you reach your goal? This creates an opportunity for you and your team members to work together to find a solution instead of feeling frustrated by the problem. Discussion is key to conflict resolution. If you find yourself in the middle of a conflict, try to communicate, start a conversation or ask things like, are there other important things I should be considering? This gives your team members or stakeholders a chance to fully lay out your concerns. But if you find yourself feeling emotional, give yourself some time to cool off so you can go into the conversation with a clearer head. If I need to write an email during a tense moment, I'll actually save it to drafts and come back to it the next day to reread it before sending to make sure that I'm being level-headed. If you find you don't understand what your team member or stakeholder is asking you to do, try to understand the context of their request. Ask them what their end goal is, what story they're trying to tell with the data or what the big picture is. By turning moments of potential conflict into opportunities to collaborate and move forward, you can resolve tension and get your project back on track. Instead of saying, \"There's no way I can do that in this time frame,\" try to re-frame it by saying, \"I would be happy to do that, but I'll just take this amount of time, let's take a step back so I can better understand what you'd like to do with the data and we can work together to find the best path forward.\" With that, we've reached the end of this section. Great job. Learning how to work with new team members can be a big challenge in starting a new role or a new project but with the skills you've picked up in these videos, you'll be able to start on the right foot with any new team you join. So far, you've learned about balancing the needs and expectations of your team members and stakeholders. You've also covered how to make sense of your team's roles and focus on the project objective, the importance of clear communication and communication expectations in a workplace, and how to balance the limitations of data with stakeholder asks. Finally, we covered how to have effective team meetings and how to resolve conflicts by thinking collaboratively with your team members. Hopefully now you understand how important communication is to the success of a data analyst. These communication skills might feel a little different from some of the other skills you've been learning in this program, but they're also an important part of your data analyst toolkit and your success as a professional data analyst. Just like all of the other skills you're learning right now, your communication skills will grow with practice and experience.\n", "source": "coursera_b", "evaluation": "exam"}
{"instructions": ["Question 1. What is the Comprehensive R Archive Network (CRAN)?\nA. A neural network trained with code for statistical analysis\nB. The repository from which R is downloaded and where packages are installed from\nC. A deep learning neural network developed by Google\nD. A feature of RStudio", "Question 2. What is a key benefit of R's popularity?\nA. It is very useful for statistical analysis\nB. It is quickly becoming the standard language for statistical analysis\nC. The quicker new functionalities make it more powerful \nD. It can detail a variety of problems", "Question 3. What is an important feature of R's community?\nA. It helps in improving the functionality of R\nB. It helps to solve R problems through many forums\nC. It helps in developing new features of R\nD. It makes the  R's community more positive", "Question 4. How is the RStudio environment divided?\nA. Into three sections each with specific and varied functions plus a main menu bar\nB. Into four quadrants\nC. Into two halves\nD. Into five panels", "Question 5. Where is the console located in the RStudio default layout?\nA. Upper-left quadrant\nB. Upper-right quadrant\nC. Lower-left quadrant\nD. Lower-right quadrant", "Question 6. What does the quadrant on the bottom right of RStudio contain?\nA. History\nB. Plots\nC. Console\nD. VIewer", "Question 7. How do you install a package from the CRAN repository?\nA. install.packages(\"package\")\nB. CRAN::install(\"package\")\nC. cran.install(\"package\")\nD. pip install CRAN", "Question 8. What is the difference between a package and a library in R?\nA. A library is a collection of packages, a package is a book within the library.\nB. A package is a collection of libraries, a library is a book within the package.\nC. A library and a package are the same things in R.\nD. The difference is that a package is a collection of functions, data, and code provided in a single format", "Question 9. What is RStudio (Select all correct answers)?\nA. A graphical user interface for R\nB. Version control software\nC. A programming language\nD. An integrated development environment for R programming", "Question 10. What does the function sessionInfo() output?\nA. The version of R you are running\nB. A listing of all of the packages you have loaded\nC. Information about your operating system\nD. None of the above"], "outputs": ["B", "C", "C", "B", "C", "B", "A", "A", "AD", "ABC"], "input": "Installing R\nNow that we've got a handle on what a data scientist is, how to find answers, and then spend some time going over data science example, it's time to get you set up to start exploring on your own. The first step of that is installing R. First, let's remind ourselves exactly what R is and why we might want to use it. R is both a programming language in an environment focused mainly on statistical analysis and graphics. It will be one of the main tools you use in this and following courses. R is downloaded from the Comprehensive R Archive Network or CRAN. While this might be your first brush with it, we will be returning to CRAN time and time again when we install packages, so keep an eye out. Outside of this course, you may be asking yourself, \"Why should I use R?\" One reason to want to use R it's popularity. R is quickly becoming the standard language for statistical analysis. This makes R a great language to learn as the more popular software is, the quicker new functionality is developed, the more powerful it becomes and the better this support there is. Additionally, as you can see in this graph, knowing R is one of the top five languages asked for in data scientist's job postings. Another benefit to R it's cost. Free. This one is pretty self-explanatory. Every aspect of R is free to use, unlike some other stats packages you may have heard of EG, SAS or SPSS. So there is no cost barrier to using R. Yet another benefit is R's extensive functionality. R is a very versatile language. We've talked about its use in stats and in graphing. But it's used can be expanded in many different functions from making websites, making maps, using GIS data, analyzing language and even making these lectures and videos. Here we are showing a dot density map made in R of the population of Europe. Each dot is worth 50 people in Europe. For whatever task you have in mind, there is often a package available for download that does exactly that. The reason that the functionality of R is so extensive is the community that has been built around R. Individuals have come together to make packages that add to the functionality of R, and more are being developed every day. Particularly, for people just getting started out with R, it's community is a huge benefit due to its popularity. There are multiple forums that have pages and pages dedicated to solving R problems. We talked about this in the getting help lesson. These forums are great both were finding other people who have had the same problem as you and posting your own new problems. Now that we've spent some time looking at the benefits of R, it is time to install it. We'll go over installation for both Windows and Mac below, but know that these are general guidelines, and small details are likely to change subsequent to the making of this lecture. Use this as a scaffold. For both Windows and Mac machines, we start at the CRAN homepage. If you're on a Windows compute, follow the link Download R for Windows and follow the directions there. If this is your first time installing R, go to the base distribution and click on the link at the top of the page that should say something like Download R version number for Windows. This will download an executable file for installation. Open the executable, and if prompted by a security warning, allow it to run. Select the language you prefer during installation and agree to the licensing information. You will next be prompted for a destination location. This will likely be defaulted to program files in a subfolder called R, followed by another sub-directory for the version number. Unless you have any issues with this, the default location is perfect. You will then be prompted to select which components should be installed. Unless you are running short on memory, installing all of the components is desirable. Next, you'll be asked about startup options and, again, the defaults are fine for this. You will then be asked where setup should place shortcuts. That is completely up to you. You can allow it to add the program to the start menu, or you can click the box at the bottom that says, \"Do not create a start menu link.\" Finally, you will be asked whether you want a desktop or quick launch icon. Up to you. I do not recommend changing the defaults for the registry entries though. After this window, the installation should begin. Test that the installation worked by opening R for the first time. If you are on a Mac computer, follow the link Download R for Mac OS X. There you can find the various R versions for download. Note, if your Mac is older than OS X 10.6 Snow Leopard, you will need to follow the directions on this page for downloading older versions of R that are compatible with those operating systems. Click on the link to the most recent version of R, which will download a PKG file. Open the PKG file and follow the prompts as provided by the installer. First, click \"Continue \"on the welcome page and again on the important information window page. Next, you will be presented with the software license agreement. Again, continue. Next you may be asked to select a destination for R, either available to all users or to a specific disk. Select whichever you feel is best suited to your setup. Finally, you will be at the standard install page. R selects a default directory, and if you are happy with that location, go ahead and click Install. At this point, you may be prompted to type in the admin password, do so and the install will begin. Once the installation is finished, go to your applications and find R. Test that the installation worked by opening R for the first time. In this lesson, we first looked at what R is and why we might want to use it. We then focused on the installation process for R on both Windows and Mac computers. Before moving on to the next lecture, be sure that you have R installed properly.\n\nInstalling R Studio\nWe've installed R and can open the R interface to input code. But there are other ways to interface with R, and one of those ways is using RStudio. In this lesson, we'll get RStudio installed on your computer. RStudio is a graphical user interface for R that allows you to write, edit, and store code, generate, view, and store plots, manage files, objects and dataframes, and integrate with version control systems to name a few of its functions. We will be exploring exactly what RStudio can do for you in future lessons. But for anybody just starting out with R coding, the visual nature of this program as an interface for R is a huge benefit. Thankfully, installation of RStudio is fairly straight forward. First, you go to the RStudio download page. We want to download the RStudio Desktop version of the software, so click on the appropriate download under that heading. You will see a list of installers for supported platforms. At this point, the installation process diverges for Macs and Windows, so follow the instructions for the appropriate OS. For Windows, select the RStudio Installer for the various Windows editions; Vista,7,8,10. This will initiate the download process. When the download is complete, open this executable file to access the installation wizard. You may be presented with a security warning at this time, allow it to make changes to your computer. Following this, the installation wizard will open. Following the defaults on each of the windows of the wizard is appropriate for installation. In brief, on the welcome screen, click next. If you want RStudio installed elsewhere, browse through your file system, otherwise, it will likely default to the program files folder, this is appropriate. Click, \"Next\". On this final page, allow RStudio to create a Start Menu shortcut. Click \"Install\". R studio is now being installed. Wait for this process to finish. R studio is now installed on your computer. Click \"Finish\". Check that RStudio is working appropriately by opening it from your start menu. For Macs, select the Macs OS X RStudio installer; Mac OS X 10.6+(64-bit). This will initiate the download process. When the download is complete, click on the downloaded file and it will begin to install. When this is finished, the applications window will open. Drag the RStudio icon into the applications directory. Test the installation by opening your Applications folder and opening the RStudio software. In this lesson, we installed RStudio, both for Macs and for Windows computers. Before moving on to the next lecture, click through the available menus and explore the software a bit. We will have an entire lesson dedicated to exploring RStudio, but having some familiarity beforehand will be helpful.\n\nRStudio Tour\nNow that we have RStudio installed, we should familiarize ourselves with the various components and functionality of it. RStudio provides a cheat sheet of the RStudio environment that you should definitely check out. Rstudio can be roughly divided into four quadrants, each with specific and varied functions plus a main menu bar. When you first open RStudio, you should see a window that looks roughly like this. You may be missing the upper-left quadrant and instead have the left side of the screen with just one region, console. If this is the case, go to \"File\" then \"New File\" then \"RScript\" and now it should more closely resemble the image. You can change the sizes of each of the various quadrants by hovering your mouse over the spaces between quadrants and click dragging the divider to resize this sections. We will go through each of the regions and describe some of their main functions. It would be impossible to cover everything that RStudio can do. So, we urge you to explore RStudio on your own too. The menu bar runs across the top of your screen and should have two rows. The first row should be a fairly standard menu starting with file and edit. Below that there was a row of icons that are shortcuts for functions that you'll frequently use. To start, let's explore the main sections of the menu bar that you will use. The first being the file menu. Here we can open new or saved files, open new or saved projects. We'll have an entire lesson in the future about our projects, so stay tuned. Save our current document or close RStudio. If you mouse over a new file, a new menu will appear that suggests the various file formats available to you. RScript and RMarkdown files are the most common file types for use, but you can also generate RNotebooks, web apps, websites or slide presentations. If you click on any one of these, a new tab in the source quadrant will open. We'll spend more time in a future lesson on RMarkdown files and their use. The Session menu has some RSpecific functions in which you can restart, interrupt or terminate R. These can be helpful if R isn't behaving or is stuck and you want to stop what it is doing and start from scratch. The Tools menu is a treasure trove of functions for you to explore. For now, you should know that this is where you can go to install new packages, see you next lecture, set up your version control software, see future lesson, linking GitHub and RStudio and set your options and preferences for how RStudio looks and functions. For now, we will leave this alone, but be sure to explore these menus on your own once you have a bit more experience with RStudio and see what you can change to best suit your preferences. The console region should look familiar to you. When you opened R, you were presented with the console. This is where you type in execute commands and where the output of said command is displayed. To execute your first command, try typing 1 plus 1 then enter at the greater than prompt. You should see the output one surrounded by square brackets followed by a two below your command. Now copy and paste the code on screen into your console and hit \"Enter.\" This creates a matrix with four rows and two columns with the numbers one through eight. To view this matrix, first look to the environment quadrant where you should see a data set called example. Click anywhere on the example line and a new tab on the source quadrant should appear showing the matrix you created. Any dataframe or matrix that you create in R can be viewed this way in RStudio. Rstudio also tells you some information about the object in the environment. Like whether it is a list or a dataframe or if it contains numbers, integers or characters. This is very helpful information to have as some functions only work with certain classes of data and knowing what kind of data you have is the first step to that. The quadrant has two other tabs running across the top of it. We'll just look at the history tab now. Your history tab should look something like this. Here you will see the commands that we have run in this session of R. If you click on any one of them, you can click to console or to source and this will either rerun the command in the console or will move the command to the source, respectively. Do so now for your example matrix and send it to source. The Source panel is where you will be spending most of your time in RStudio. This is where you store the R commands that you want to save it for later, either as a record of what you did or as a way to rerun the code. We'll spend a lot of time in this quadrant when we discuss RMarkdown. But for now, click the \"Save\" icon along the top of this quadrant and save this script is my_first_R_Script.R. Now you will always have a record of creating this matrix. The final region we'll look at occupies the bottom right of the RStudio window. In this quadrant, five tabs run across the top, Files, Plots, Packages, Help, and Viewer. In files, you can see all of the files in your current working directory. If this isn't where you want to save or retrieve files from, you can also change the current working directory in this tab using the ellipsis at the far right, finding the desired folder and then under the More cog wheel, setting this new folder as the working directory. In the plots tab, if you generate a plot with your code, it will appear here. You can use the arrows to navigate to previously generated plots. The zoom function will open the plot in a new window that is much larger than the quadrant. \"Export\" is how you save the plot. You can either save it as an image or as a PDF. The broom icon clears all plots from memory. The \"Packages\" tab will be explored more in depth in the next lesson on R packages. Here you can see all the packages you have installed, load and unload these packages and update them. The \"Help\" tab is where you find the documentation for your R packages in various functions. In the upper right of this panel, there is a search function for when you have a specific function or package in question. In this lesson, we took a tour of the RStudio software. We became familiar with the main menu and its various menus. We looked at the console where our code is input and run. We then moved onto the environment panel that lists all of the objects that had been created within an R session and allows you to view these objects in a new tab and source. In this same quadrant, there is a history tab that keeps a record of all commands that have been run. It also presents the option to either rerun the command in the console or send the command to source to be saved. Source is where you save your R commands. The bottom-right quadrant contains a listing of all the files in your working directory, displays generated plots, lists your installed packages, and supplies help files for when you need some assistance. Take some time to explore RStudio on your own.\n\nR Packages\nNow that we've installed R in RStudio and have a basic understanding of how they work together, we can get at what makes R so special, packages. So far, anything we've played around with an R uses the Base R system. Base R or everything included in R when you download it has rather basic functionality for statistics and plotting, but it can sometimes be limiting. To expand upon R's basic functionality, people have developed packages. A package is a collection of functions, data, and code conveniently provided in a nice complete format for you. At the time of writing, there are just over 14,300 packages available to download, each with their own specialized functions and code, all for some different purpose. R package is not to be confused with the library. These two terms are often conflated in colloquial speech about R. A library is the place where the package is located on your computer. To think of an analogy, a library is well, a library, and a package is a book within the library. The library is where the book/packages are located. Packages are what make R so unique. Not only does Base R have some great functionality, but these packages greatly expand its functionality. Perhaps, most special of all, each package is developed and published by the R community at large and deposited in repositories. A repository is a central location where many developed packages are located and available for download. There are three big repositories. They are the Comprehensive R Archive Network, or CRAN, which is R's main repository with over 12,100 packages available. There is also the Bioconductor repository, which is mainly for Bioinformatic focus packages. Finally, there is GitHub, a very popular, open source repository that is not R specific. So, you know where to find packages. But there are so many of them. How can you find a package that will do what you are trying to do in R? There are a few different avenues for exploring packages. First, CRAN groups all of its packages by their functionality/topic into 35 themes. It calls this its task view. This at least allows you to narrow the packages, you can look through to a topic relevant to your interests. Second, there is a great website. R documentation, which is a search engine for packages and functions from CRAN, Bioconductor, and GitHub, that is, the big three repositories. If you have a task in mind, this is a great way to search for specific packages to help you accomplish that task. It also has a Task View like CRAN that allows you to browse themes. More often, if you have a specific task in mind, Googling that task followed by R package is a great place to start. From there, looking at tutorials, vignettes, and forums for people already doing what you want to do is a great way to find relevant packages. Great. You found a package you want. How do you install it? If you are installing from the CRAN repository, use the Install Packages function with the name of the package you want to install in quotes between the parentheses. Note, you can use either single or double quotes. For example, if you want to install the package ggplot2, you would use install.packages(\"ggplot2\"). Try doing so in your R Console. This command downloads the ggplot2 package from CRAN and installs it onto your computer. If you want to install multiple packages at once, you can do so by using a character vector with the names of the packages separated by commas as formatted here. If you want to use RStudio's Graphical Interface to install packages, go to the Tools menu, and the first option should be Install Packages. If installing from CRAN, selected is the repository and type the desired packages in the appropriate box. The Bioconductor repository uses their own method to install packages. First, to get the basic functions required to install through Bioconductor, use source(\"https://bioconductor.org/biocLite.R\") This makes the main install function of Bioconductor biocLite available to you. Following this you call the package you want to install in quote between the parentheses of the biocLite command as seen here for the GenomicRanges package. Installing from GitHub is a more specific case that you probably won't run into too often. In the event you want to do this, you first must find the package you want on GitHub and take note of both the package name and the author of the package. The general workflow is installing the devtools package only if you don't already have devtools installed. If you've been following along with this lesson, you may have installed it when we were practicing installations using the R console, then you load the devtools package using the library function SO. More on with this command is doing in a few seconds. Finally, using the command install_github calling the authors GitHub username followed by the package name. Installing a package does not make its functions immediately available to you. First, you must load the package into R. To do so, use the library function. Think of this like any other software you install on your computer. Just because you've installed the program doesn't mean it's automatically running. You have to open the program. Same with R you've installed it but now you have to open it. For example, to open the ggplot2 package, you would use the library function and call it ggplot2. Note do not put the package name in quotes. Unlike when you are installing the packages, the library command does not accept package names in quotes. There is an order to loading packages. Some packages require other packages to be loaded first, aka dependencies. That package is manual/help pages. We'll help you out and finding that order if they are picky. If you want to load a package using the RStudio interface, in the lower right quadrant, there is a tab called packages that list set all of the packages in a brief description as well as the version number of all of the packages you have installed. To load a package, just click on the checkbox beside the package name. Once you've got a package, there are a few things you might need to know how to do. If you aren't sure if you've already installed the package or want to check with packages are installed, you can use either of the Install Packages or library commands with nothing between the parentheses to check. In RStudio, that package tab introduced earlier is another way to look at all of the packages you have installed. You can check what packages need an update with a call to the functional packages. This will identify all packages that have been updated since you install them/Last updated them. To update all packages, use update packages. If you only want to update a specific package, just use once again install packages. Within the RStudio interface still in that Packages tab, you can click Update which will list all of the packages that are not up-to-date. It gives you the option to update all of your packages or allows you to select specific packages. You will want to periodically checking on your packages and check if you've fallen out of date, be careful though. Sometimes an update can change the functionality of certain functions. So if you rerun some old code, the command may be changed or perhaps even outright gone and you will need to update your CO2. Sometimes you want to unload a package in the middle of a script. The package you have loaded may not play nicely with another package you want to use. To unload a given package, you can use the detach function. For example, you would type detach package:ggplot2 then unload equals true in the format shown. This would unload the ggplot2 package that we loaded earlier. Within the RStudio interface in the Packages tab, you can simply unload a package by unchecking the box beside the package name. If you no longer want to have a package installed, you can simply uninstall it using the function Removed.packages. For example, remove packages followed by ggplot2 try that. But then actually reinstalled the ggplot2 package. It's a super useful plotting package. Within RStudio in the Packages tab, clicking on the X at the end of a package's row will uninstall that package. Sometimes, when you are looking at a package that you might want to install, you will see that it requires a certain version of R to run. To know if you can use that package, you need to know what version of R you are running. One way to know your R version is to check when you first open R or RStudio. The first thing it outputs in the console tells you what version of R is currently running. If you didn't pay attention at the beginning, you can type version into the console and it will output information on the R version you're running. Another helpful command is session info. It will tell you what version of R you are running along with a listing of all of the packages you have loaded. The output of this command is a great detail to include when posting a question to forums. It tells potential helpers a lot of information about your OS, R, and the packages plus their version numbers that you are using. In all of this information about packages, we have not actually discussed how to use a package's functions. First, you need to know what functions are included within a package. To do this, you can look at the manner help pages included in all well-made packages. In the console, you can use the help function to access a package's help file. Try using the help function calling package equals ggplot2 and you will see all of the many functions that ggplot2 provides. Within the RStudio interface, you can access the help files through the Packages tab. Again, clicking on any package name should open up these associated help files in the Help tab found in that same quadrant beside the Packages tab. Clicking on any one of these help pages will take you to that functions help page that tells you what that function is for and how to use it. Once you know what function within a package you want to use, you simply call it in the console like any other function we've been using throughout this lesson. Once a package has been loaded, it is as if it were a part of the base R functionality. If you still have questions about what functions within a package are right for you or how to use them, many packages include vignettes. These are extended help files that include an overview of the package and its functions, but often they go the extra mile and include detailed examples of how to use the functions in plain words that you can follow along with to see how to use the package. To see the vignettes included in a package, you can use the browseVignettes function. For example, let's look at the vignettes included in ggplot2 using browseVignettes followed by ggplot2, you should see that there are two included vignettes. Extending ggplot2 and aesthetics specification. Exploring the aesthetic specifications vignette is a great example of how vignettes can be helpful clear instructions on how to use the included functions. In this lesson, we've explored our packages in depth. We examined what a package is is and how it differs from a library, what repositories are, and how to find a package relevant to your interests. We investigated all aspects of how packages work, how to install them from the various repositories, how to load them, how to check which packages are installed, and how to update, uninstall, and unload packages. We took a small detour and looked at how to check with version of R you have which is often an important detail to know when installing packages. Finally, we spent some time learning how to explore help files and vignettes which often give you a good idea of how to use a package and all of its functions.\n\nProjects in R\nOne of the ways people organize their work in R is through the use of R projects. A built-in functionality of R Studio that helps to keep all your related files together. R Studio provides a great guide on how to use projects. So, definitely check that out. First off, what is an R project? When you make a project, it creates a folder where all files will be kept, which is helpful for organizing yourself and keeping multiple projects separate from each other. When you reopen a project, R Studio remembers what files were open and will restore the work environment as if you have never left, which is very helpful when you are starting backup on a project after some time off. Functionally, creating a project in R will create a new folder and assign that as the working directory so that all files generated will be assigned to the same directory. The main benefit of using projects is that it starts the organization process off right. It creates a folder for you and now you have a place to store all of your input data, your code and the output of your code. Everything you are working on within a project is self-contained, which often means finding things is much easier. There's only one place to look. Also, since everything related to one project is all in the same place, it is much easier to share your work with others either by directly sharing the folders slash files, or by associating it with version control software. We'll talk more about linking projects in R with version control systems in a future lesson entirely dedicated to the topic. Finally, since R Studio remembers what documents you had opened when you close this session, it is easier to pick a project up after a break. Everything is set up just as you left it. There are three ways to make a project. First, you can make it from scratch. This will create a new directory for all your files to go in. Or you can create a project from an existing folder. This will link an existing directory with R Studio. Finally, you can link a project from version control. This will clone an existing project onto your computer. Don't worry too much about this one. You'll get more familiar with it in the next few lessons. Let's create a project from scratch, which is often what you will be doing. Open R Studio and under \"File,\" select \"New Project.\" You can also create a new project by using the projects toolbar and selecting new project in the drop-down menu, or there is a new project shortcut in the toolbar. Since we are starting from scratch, select \"New Directory.\" When prompted about the project type, select \"New Project.\" Pick a name for your project and for this time, save it to your desktop. This will create a folder on your desktop where all of the files associated with this project will be kept. Click create project. A blank R Studio session should open. A few things to note. One, in the files quadrant of the screen, you can see that R Studio has made this new directory, your working directory and generated a single file with the extension, \"R project\". Two, in the upper right of the window, there is a project's toolbar that states the name of your current project and has a drop-down menu with a few different options that we'll talk about in a second. Opening an existing project is as simple as double clicking the R Project file on your computer. You can accomplish the same from within R Studio by opening R Studio and going to file then open project. You can also use the project toolbar and open the drop down menu and select \"Open Project.\" Quitting a project is as simple as closing your R Studio window. You can also go to file \"Close project,\" and this will do the same. Finally, you can use the project toolbar by clicking on the drop down menu and choosing closed project. All of these options will quit a project and doing so will cause R Studio to write which documents are currently open so they can be restored when you start back up again and it then closes the R session. When you set up your project, you can tell it to save environment. So, for example, all of your variables in data tables will be pre-loaded when you reopen the project, but this is not the default behavior. The projects toolbar is also an easy way to switch between projects. Click on the drop-down menu and choose \"Open Project\" and find your new project you want to open. This will save the current project, close it and then open the new project within the same window. If you want multiple projects open at the same time, do the same, but instead, select \"Open Project in New Session.\" This can also be accomplished through the file menu, where those same options are available. When you are setting up a project, it can be helpful to start out by creating a few directories. Try a few strategies and see what works best for you. But most file structures are set up around having a directory containing the raw data. A directory that you keep scripts slash R files in, and a directory for the output of your code. If you set up these boulders before you start, it can save you organizational headaches later on in a project when you can't quite remember where something is. In this lesson, we've covered what projects in R are. Why you might want to use them, how to open, close or switch between projects and some best practices to best set you up for organizing yourself.\n", "source": "coursera_a", "evaluation": "exam"}
{"instructions": ["Question 1. Which of the following does NOT accurately describe what 'merge' means in the context of Git\nA. To delete a file from the repository.\nB. To create two simultaneous copies of the same file.\nC. To incorporate independent edits of the same file into a single unified file.\nD. To merge two repositories into a unified one.", "Question 2. What is  not the purpose of \"staging\" in Git?\nA. To prepare a file for deletion.\nB. To prepare a file for a commit.\nC. To download a file from the repository.\nD. To prepare a file for add", "Question 3. What is a repository in terms of version control?\nA. The location where all the version controlled files and their changes are located.\nB. The location where only the final versions of files are stored.\nC. A type of software used for version control.\nD. A GitHub repository and their changes are located..", "Question 4. What does \"pull\" mean in the context of Git?\nA. To delete a file from the repository.\nB. To upload a file to the repository.\nC. To update your local version of the repository to the current version.\nD. To pull a file to the repository.", "Question 5. Which of the following is false about Git?\nA. Git is a paid version control system.\nB. Git keeps a local copy of your work and revisions, which can be edited offline.\nC. Git does not interface well with RStudio.\nD. Git is a version control tool from GitHub", "Question 6. What is a commit in the context of version control?\nA. A commit is to save your edits and the changes made.\nB. A commit is to update the repository with your edits.\nC. A commit is when independent edits of the same file are incorporated into a single unified file.\nD. A commit should be done after git add", "Question 7. Which of the following statements is NOT true about a 'fork' in the context of version control?\nA. A fork is when multiple people make changes to the same file and Git is unable to merge the edits.\nB. A fork is when the same file has two simultaneous copies.\nC. A fork is a personal copy of a repository that you have taken from another person.\nD. A fork is to copy other people's code on github", "Question 8. How do you link Git to RStudio?\nA. In RStudio, open the File menu and choose \"New Git Repository\".\nB. In RStudio, use the command git init in the console.\nC. In RStudio,  go to Tools,  then click Git option and that will generate \".git\" folder\nD. In RStudio, go to Tools, then Global Options, then Git/SVN and confirm the correct directory for git.exe.", "Question 9. How to clone an existing project from GitHub to RStudio?\nA. Go to RStudio > New Project > Version Control > Git > Paste the repository URL > Create the project.\nB. Open Terminal > Use the command git clone followed by the repository URL.\nC. Go to GitHub > Click on the \"Clone or download\" button > Download ZIP > Unzip the project on your local machine > Open the project in RStudio.\nD. Go to RStudio  > Open the project > Use git clone command", "Question 10. How do you link a local project, which is not under version control, to Git and GitHub?\nA. Create a new repository on GitHub > Go to RStudio and select \"Version Control\" under New Project > Paste the repository URL.\nB. In terminal, navigate to the project directory > Initialize the directory as a Git repository using \"git init\" > Commit the changes > Create a new repository on GitHub with the same name > Link the local repository to GitHub using the command line.\nC. In RStudio, select \"New Git Repository\" under the File menu > Commit the changes > Create a new repository on GitHub with the same name > Push the changes to the GitHub repository.\nD. In RStudio, Use \"git --config\" to set Git configuration values on a global or local project level>  Initialize the directory as a Git repository using \"git init\"  > Create the \".git\" folder >  Link the local repository to GitHub using the command line."], "outputs": ["ABD", "ACD", "A", "C", "ACD", "A", "ABD", "D", "A", "B"], "input": "Version Control\nNow that we've got a handle on our RStudio and projects, there are a few more things we want to set you up with before moving on to the other courses, understanding version control, installing Git, and linking Git with RStudio. In this lesson, we will give you a basic understanding of version control. First things first, what is version control? Version control is a system that records changes that are made to a file or a set of files over time. As you make edits, the version control system takes snapshots of your files and the changes and then saves those snapshots so you can refer, revert back to previous versions later if need be. If you've ever used the track changes feature in Microsoft Word, you have seen a rudimentary type of version control in which the changes to a file are tracked and you can either choose to keep those edits or revert to the original format. Version control systems like Git are like a more sophisticated track changes in that, they are far more powerful and are capable of meticulously tracking successive changes on many files with potentially many people working simultaneously on the same groups of files. Hopefully, once you've mastered version control software, paper final final two actually finaldoc.docx will be a thing of the past for you. As we've seen in this example, without version control, you might be keeping multiple, very similar copies of a file and this could be dangerous. You might start editing the wrong version not recognizing that the document labeled final has been further edited to final two and now all your new changes have been applied to the wrong file. Version control systems help to solve this problem by keeping a single updated version of each file with a record of all previous versions and a record of exactly what changed between the versions which brings us to the next major benefit of version control. It keeps a record of all changes made to the files. This can be of great help when you are collaborating with many people on the same files. The version control software keeps track of who, when, and why those specific changes were made. It's like track changes to the extreme. This record is also helpful when developing code. If you realize after sometime that you made a mistake and introduced an error, you can find the last time you edited the particular bit of code, see the changes you made and revert back to that original, unbroken code leaving everything else you've done in the meanwhile on touched. Finally, when working with a group of people on the same set of files, version control is helpful for ensuring that you aren't making changes to files that conflict with other changes. If you've ever shared a document with another person for editing, you know the frustration of integrating their edits with a document that has changed since you sent the original file. Now, you have two versions of that same original document. Version control allows multiple people to work on the same file and then helps merge all of the versions of the file and all of their edits into one cohesive file. Git is a free and open source version control system. It was developed in 2005 and has since become the most commonly used version control system around. Stack Overflow which should sound familiar from our getting help lesson surveyed over 60,000 respondents on which version control system they use. As you can tell from the chart, Git is by far the winner. As you become more familiar with Git and how it works in interfaces with your projects, you'll begin to see why it has risen to the height of popularity. One of the main benefits of Git is that it keeps a local copy of your work and revisions which you can then netted offline. Then once you return to internet service, you can sync your copy of the work with all of your new edits and track changes to the main repository online. Additionally, since all collaborators on a project had their own local copy of the code, everybody can simultaneously work on their own parts of the code without disturbing the common repository. Another big benefit that we'll definitely be taking advantage of is the ease with which RStudio and Git interface with each other. In the next lesson, we'll work on getting Git installed and linked with RStudio and making a GitHub account. GitHub is an online interface for Git. Git is software used locally on your computer to record changes. GitHub is a host for your files and the records of the changes made. You can think of it as being similar to Dropbox. The files are on your computer but they are also hosted online and are accessible from many computer. GitHub has the added benefit of interfacing with Git to keep track of all of your file versions and changes. There is a lot of vocabulary involved in working with Git and often the understanding of one word relies on your understanding of a different Git concept. Take some time to familiarize yourself with the following words and go over it a few times to see how the concepts relate. A repository is equivalent to the projects folder or directory. All of your version controlled files and the recorded changes are located in a repository. This is often shortened to repo. Repositories are what are hosted on GitHub and through this interface you can either keep your repositories private and share them with select collaborators or you can make them public. Anybody can see your files in their history. To commit is to save your edits and the changes made. A commit is like a snapshot of your files. Git compares the previous version of all of your files in the repo to the current version and identifies those that have changed since then. Those that have not changed, it maintains that previously stored file untouched. Those that have changed, it compares the files, loads the changes and uploads the new version of your file. We'll touch on this in the next section, but when you commit a file, typically you accompany that file change with a little note about what you changed and why. When we talk about version control systems, commits are at the heart of them. If you find a mistake, you will revert your files to a previous commit. If you want to see what has changed in a file over time, you compare the commits and look at the messages to see why and who. To push is to update the repository with your edits. Since Git involves making changes locally, you need to be able to share your changes with the common online repository. Pushing is sending those committed changes to that repository so now everybody has access to your edits. Pulling is updating your local version of the repository to the current version since others may have edited in the meanwhile. Because the shared repository is hosted online in any of your collaborators or even yourself on a different computer could it made changes to the files and then push them to the shared repository. You are behind the times, the files you have locally on your computer may be outdated. So, you pull to check if you were up to date with the main repository. One final term you must know is staging which is the act of preparing a file for a commit. For example, if since your last commit you have edited three files for completely different reasons, you don't want to commit all of the changes in one go, your message on why you are making the commit in what has changed will be complicated since three files have been changed for different reasons. So instead, you can stage just one of the files and prepare it for committing. Once you've committed that file, you can stage the second file and commit it and so on. Staging allows you to separate out file changes into separate commits, very helpful. To summarize these commonly used terms so far and to test whether you've got the hang of this, files are hosted in a repository that is shared online with collaborators. You pull the repository's contents so that you have a local copy of the files that you can edit. Once you are happy with your changes to a file, you stage the file and then commit it. You push this commit to the shared repository. This uploads your new file and all of the changes and is accompanied by a message explaining what changed, why, and by whom. A branch is when the same file has two simultaneous copies. When you were working locally in editing a file, you have created a branch where your edits are not shared with the main repository yet. So, there are two versions of the file. The version that everybody has access to on the repository and your local edited version of the file. Until you push your changes and merge them back into the main repository, you are working on a branch. Following a branch point, the version history splits into two and tracks the independent changes made to both the original file in the repository that others may be editing and tracking your changes on your branch and then merges the files together. Merging is when independent edits of the same file are incorporated into a single unified file. Independent edits are identified by Git and are brought together into a single file with both sets of edits incorporated. But you can see a potential problem here. If both people made an edit to the same sentence that precludes one of the edit from being possible, we have a problem. Git recognizes this disparity, conflict and asks for user assistance in picking which edit to keep. So, a conflict is when multiple people make changes to the same file and Git is unable to merge the edits. You are presented with the option to manually try and merge the edits or to keep one edit over the other. When you clone something, you are making a copy of an existing Git repository. If you have just been brought on to a project that has been tracked with version control, you will clone the repository to get access to and create a local version of all of the repository's files and all of the track changes. A fork is a personal copy of a repository that you have taken from another person. If somebody is working on a cool project and you want to play around with it, you can fork their repository and then when you make changes, the edits are logged on your repository not theirs. It can take some time to get used to working with version control software like Git, but there are a few things to keep in mind to help establish good habits that will help you out in the future. One of those things is to make purposeful commits. Each commit should only addressed as single issue. This way if you need to identify when you changed a certain line of code, there is only one place to look to identify the change and you can easily see how to revert the code. Similarly, making sure you write formative messages on each commit is a helpful habit to get into. If each message is precise in what was being changed, anybody can examine the committed file and identify the purpose for your change. Additionally, if you are looking for a specific edit you made in the past, you can easily scan through all of your commits to identify those changes related to the desired edit. Finally, be cognizant of their version of files you are working on. Frequently check that you are up to date with the current repo by frequently pulling. Additionally, don't hoard your edited files. Once you have committed your files and written that helpful message, you should push those changes to the common repository. If you are done editing a section of code and are planning on moving onto an unrelated problem, you need to share that edit with your collaborators. Now that we've covered what version control is and some of the benefits, you should be able to understand why we have three whole lessons dedicated to version control and installing it. We looked at what Git and GitHub are and then covered much of the commonly used and sometimes confusing vocabulary inherent to version control work. We then quickly went over some best practices to using Git, but the best way to get a hang of this all is to use it. Hopefully, you feel like you have a better handle on how Git works now. So, let's move on to the next lesson and get it installed.\n\nGithub and Git\nNow that we've got a handle on what version control is. In this lesson, you will sign up for a GitHub account, navigate around the GitHub website to become familiar with some of its features and install and configure Git. All in preparation for linking both with your RStudio. As we previously learned, GitHub is a cloud-based management system for your version controlled files. Like Dropbox, your files are both locally on your computer and hosted online and easily accessible. Its interface allows you to manage version control and provides users with a web-based interface for creating projects, sharing them, updating code, etc. To get a GitHub account, first go to www.github.com. You will be brought to their homepage where you should fill in your information, make a username, put in your email, choose a secure password, and click sign up for GitHub. You should now be logged into GitHub. In the future, to log onto GitHub, go to github.com where you will be presented with a homepage. If you aren't already logged in, click on the sign in link at the top. Once you've done that, you will see the login page where you will enter in your username and password that you created earlier. Once logged in, you will be back at github.com but this time the screen should look like this. We're going to take a quick tour of the GitHub website and we'll particularly focus on these sections of the interface, user settings, notifications, help files, and the GitHub guide. Following this tour, will make your very first repository using the GitHub guide. First, let's look at your user settings. Now that you've logged onto GitHub, we should fill out some of your profile information and get acquainted with the account settings. In the upper right corner, there is an icon with a narrow beside it. Click this and go to your profile. This is where you control your account from and can view your contribution, histories, and repositories. Since you are just starting out, you aren't going to have any repositories or contributions yet, but hopefully we'll change that soon enough. What we can do right now is edit your profile. Go to edit profile along the left-hand edge of the page. Here, take some time and fill out your name and a little description of yourself in the bio box. If you like, upload a picture of yourself. When you are done, click update profile. Along the left-hand side of this page, there are many options for you to explore. Click through each of these menus to get familiar with the options available to you. To get you started, go to the account page. Here, you can edit your password or if you are unhappy with your username, change it. Be careful though, there can be unintended consequences when you change your username if you are just starting out and don't have any content yet, you'll probably be safe though. Continue looking through the personal setting options on your own. When you're done, go back to your profile. Once you've had a bit more experienced with GitHub, you'll eventually end up with some repositories to your name. To find those, click on the repositories link on your profile. For now, it will probably look like this. By the end of the lecture though, check back to this page to find your newly created repository. Next, we'll check out the notifications menu. Along the menu bar across the top of your window, there is a bell icon representing your notifications. Click on the bell. Once you become more active on GitHub and are collaborating with others, here is where you can find messages and notifications for all the repositories, teams, and conversations you are a part of. Along the bottom of every single page there is the help button. GitHub has a great help system in place. If you ever have a question about GitHub, this should be your first point to search. Take some time now and look through the various help files and see if any catch your eye. GitHub recognizes that this can be an overwhelming process for new users and as such have developed a mini tutorial to get you started with GitHub. Go through this guide now and create your first repository. When you're done, you should have a repository that looks something like this. Take some time to explore around the repository. Check out your commit history so far. Here you can find all of the changes that have been made to the repository and you can see who made the change, when they made the change, and provided you wrote an appropriate commit message. You can see why they made the change. Once you've explored all of the options in the repository, go back to your user profile. It should look a little different from before. Now when you are on your profile, you can see your latest repository created. For a complete listing of your repositories, click on the Repositories tab. Here you can see all of your repositories, a brief description, the time of the last edit, and along the right-hand side, there is an activity graph showing one and how many edits have been made on the repository. As you may remember from our last lecture, Git is the free and open-source version control system which GitHub is built on. One of the main benefits of using the Git system is its compatibility with RStudio. However, in order to link the two software together, we first need to download and install Git on your computer. To download Git, go to git-scm.com/download. Click on the appropriate download link for your operating system. This should initiate the download process. We'll first look at the install process for Windows computers and follow that with Mac installation steps. Follow along with the relevant instructions for your operating system. For Windows computers, once the download is finished, open the.exe file to initiate the installation wizard. If you receive a security warning, click run and to allow. Following this, click through the installation wizard generally accepting the default options unless you have a compelling reason not to. Click install and allow the wizard to complete the installation process. Following this, check the launch Git Bash option. Unless you are curious, deselect the View Release Notes box as you are probably not interested in this right now. Doing so, a command line environment will open. Provided you accepted the default options during the installation process, there will now be a start menu shortcut to launch Git Bash in the future. You have now installed Git. For Macs, we will walk you through the most common installation process. However, there are multiple ways to get Git onto your Mac. You can follow the tutorials at www.@lash.com/git/tutorials/installgitforalternativeinstallationrats. After downloading the appropriate git version for Macs, you should have downloaded a dmg file for installation on your Mac. Open this file. This will install Git on your computer. A new window will open. Double click on the PKG file and an installation wizard will open. Click through the options accepting the defaults. Click Install. When prompted, close the installation wizard. You have successfully installed Git. Now that Git is installed, we need to configure it for use with GitHub in preparation for linking it with RStudio. We need to tell Git what your username and email are so that it knows how to name each commit is coming from you. To do so, in the command prompt either Git Bash for Windows or terminal for Mac, type git config --global user.name \"Jane Doe\" with your desired username in place of Jane Doe. This is the name each commit will be tagged with. Following this, in the command prompt type, git config --global user.email janedoe@gmail.com making sure to use the same email address you signed up for GitHub with. At this point, you should be set for the next step. But just to check, confirm your changes by typing git config --list. Doing so, you should see the username and email you selected above. If you notice any problems or want to change these values, just retype the original config commands from earlier with your desired changes. Once you are satisfied that your username and email is correct, exit the command line by typing exit and hit enter. At this point, you are all set up for the next lecture. In this lesson, we signed up for a GitHub account and toured the GitHub website. We made your first repository and filled in some basic profile information on GitHub. Following this, we installed Git on your computer and configured it for compatibility with GitHub and RStudio.\n\nLinking Github and R Studio\nNow that we have both RStudio and Git set up on your computer in a GitHub account, it's time to link them together so that you can maximize the benefits of using RStudio in your version control pipelines. To link RStudio in Git, in RStudio, go to Tools, then Global Options, then Git/SVN. Sometimes the default path to the Git executable is not correct. Confirm that git.exe resides in the directory that RStudio has specified. If not, change the directory to the correct path. Otherwise, click \"Okay\" or \"Apply\". Rstudio and Git are now linked. Now, to link RStudio to GitHub in that same RStudio option window, click \"Create RSA Key\" and when there is complete, click \"Close\". Following this, in that same window again, click \"View public key\" and copy the string of numbers and letters. Close this window. You have now created a key that is specific to you which we will provide to GitHub so that it knows who you are when you commit a change from within RStudio. To do so, go to github.com, log in if you are not already, and go to your account settings. There, go to SSH and GPG keys and click \"New SSH key\". Paste in the public key you have copied from RStudio into the key box and give it a title related to RStudio. Confirm the addition of the key with your GitHub password. GitHub and RStudio are now linked. From here, we can create a repository on GitHub and link to RStudio. To do so, go to GitHub and create a new repository by going to your Profile, Repositories and New. Name your new test repository and give it a short description. Click \"Create Repository\", copy the URL for your new repository. In RStudio, go to File, New Project, select Version Control, select Git as your version control software. Paste in the repository URL from before, select the location where you would like the project stored. When done, click on \"Create Project\". Doing so will initialize a new project linked to the GitHub repository and open a new session of RStudio. Create a new R script by going to File, New File, R Script and copy and paste the following code: print(\"This file was created within RStudio\") and then on a new line paste, print(\"And now it lives on GitHub\"). Save the file. Note that when you do so, the default location for the file is within the new project directory you created earlier. Once that is done, looking back at RStudio, in the Git tab of the environment quadrant, you should see your file you just created. Click the checkbox under Staged to stage your file. Click on it. A new window should open that lists all of the changed files from earlier and below that shows the differences in the stage files from previous versions. In the upper quadrant, in the.Commit message box, write yourself a commit message. Click Commit, close the window. So far, you have created a file, saved it, staged it, and committed it. If you remember your version control lecture, the next step is to push your changes to your online repository, push your changes to the GitHub repository, go to your GitHub repository and see that the commit has been recorded. You've just successfully pushed your first commit from within RStudio to GitHub. In this lesson, we linked Git and RStudio so that RStudio recognizes you are using it as your version control software. Following that, we linked RStudio to GitHub so that you can push and pull repositories from within RStudio. To test this, we created a repository on GitHub, linked it with a new project within RStudio, created a new file and then staged, committed and pushed the file to your GitHub repository.\n\nProjects under Version Control\nIn the previous lesson, we linked RStudio with Git and GitHub. In doing this, we created a repository on GitHub and linked it to RStudio. Sometimes, however, you may already have an R project that isn't yet under version control or linked with GitHub. Let's fix that. So, what if you already have an R project that you've been working on but don't have it linked up to any version control software tat tat. Thankfully, RStudio and GitHub recognize this can happen and steps in place to help you. Admittedly, this is slightly more troublesome to do than just creating a repository on GitHub and linking it with RStudio before starting the project. So, first, let's set up a situation where we have a local project that isn't under version control. Go to File, New Project, New Directory, New Project and name your project. Since we are trying to emulate a time where you have a project not currently under version control, do not click Create a git repository, click Create Project. We've now created an R project that is not currently under version control. Let's fix that. First, let's set it up to interact with Git. Open Git Bash or Terminal and navigate to the directory containing your project files. Move around directories by typing CD for change directory, followed by the path of the directory. When the command prompt in the line before the dollar sign says the correct location of your project, you are in the correct location. Once here, type git init followed by GitHub period. This initializes this directory as a Git repository and adds all of the files in the directory to your local repository. Commit these changes to the Git repository using git commit dash m initial commit. At this point, we have created an R project and have now linked it to Git version control. The next step is to link this with GitHub. To do this, go to github.com. Again, create a new repository. Make sure the name is the exact same as your R project and do not initialize the readme file, gitignore or license. Once you've created this repository, you should see that there is an option to push an existing repository from the command line with instructions below containing code on how to do so. In Git Bash or Terminal, copy and paste these lines of code to link your repository with GitHub. After doing so, refresh your GitHub page and it should now look something like this. When you reopen your project in RStudio, you should now have access to the Git tab in the upper right quadrant then can push to GitHub from within RStudio any future changes. If there is an existing project that others are working on that you are asked to contribute to, you can link the existing project with your RStudio. It follows the exact same premises that from the last lesson where you created a GitHub repository and then cloned it to your local computer using RStudio. In brief, in RStudio, go to File, New Project, Version Control. Select Git as your version control system, and like in the last lesson, provide the URL to the repository that you are attempting to clone and select a location on your computer to store the files locally. Create the project. All the existing files in the repository should now be stored locally on your computer and you have the ability to push at it's from your RStudio interface. The only difference from the last lesson is that you did not create the original repository. Instead, you cloned somebody else's. In this lesson, we went over how to convert an existing project to be under Git version control using the command line. Following this, we linked your newly version controlled project to GitHub using a mix of GitHub commands in the command line. We then briefly recap how to clone an existing GitHub repository to your local machine using RStudio.\n", "source": "coursera_a", "evaluation": "exam"}
{"instructions": ["Question 1. How can you create an R code chunk in an R Markdown document?\nA. By surrounding the code with three backticks and lowercase r.\nB. By surrounding the code with three backticks and uppercase R.\nC. By surrounding the code with three single quotes and lowercase r.\nD. By surrounding the code with three single quotes and uppercase R.", "Question 2. Which of the following is a key benefit of using R Markdown?\nA. It allows you to create documents that are easily sharable but not reproducible.\nB. It allows you to combine text and code chunks, facilitating reproducible research.\nC. It requires proprietary software, ensuring high-quality document formatting.\nD. Markdown enables faster creating and editing of blog posts", "Question 3. What is the result of not ending each line of a bulleted list with two spaces in R Markdown?\nA. The list items will be rendered in bold text.\nB. The list items will be concatenated into a single line.\nC. The spacing between the list items may not be rendered correctly.\nD. The file will not be saved correctly.", "Question 4. In a scientific study investigating the impact of a new drug on heart disease, what kind of analysis would be most appropriate to determine if the drug is causing any changes in the patient's health?\nA. Descriptive\nB. Exploratory\nC. Causal\nD. Predictive", "Question 5. if a study is conducted to precisely understand how changes in temperature affect the growth rate of a specific plant species, what kind of analysis would this be?\nA. Descriptive\nB. Causal\nC. Inferential\nD. Mechanistic", "Question 6. You have a database containing historical data on the stock market and you want to predict future stock prices based on this data. What type of analysis would be most suitable?\nA. Descriptive\nB. Exploratory\nC. Inferential\nD. Predictive", "Question 7. If you want to estimate the life expectancy in an entire country based on a representative sample, which type of analysis  you would not like to use?\nA. Descriptive\nB. Exploratory\nC. Inferential\nD. Predictive\n", "Question 8. Which type of analysis would be used to examine relationships between different measurements without necessarily determining causation?\nA. Descriptive\nB. Exploratory\nC. Inferential\nD. Predictive", "Question 9. What is the correct order of steps in the experimental design process?\nA. Develop your hypothesis, formulate questions, identify problems, design the setup, collect data\nB. Formulate questions, develop your hypothesis, design the setup, identify problems, collect data\nC. Identify problems, formulate questions, develop your hypothesis, design the setup, collect data\nD. Formulate questions, identify problems, develop your hypothesis, design the setup, collect data", "Question 10. Which term refers to the variable manipulated by the experimenter in a study?\nA. Dependent variable\nB. Confounder\nC. Independent variable\nD. Control variable", "Question 11. What is \"p-hacking\" in the context of experimental design and data analysis? Select options that are not true.\nA. Manipulating p-values to achieve statistical significance\nB. Adjusting experimental procedures to minimize p-values\nC. Hiding high p-values in the presentation of data\nD. Creating new hypotheses after seeing the data", "Question 12. Which of the following does NOT correctly describe what 'variety' refers to in the context of Big Data?\nA. The diversity of data types and sources available for analysis\nB. The speed at which data is being generated and collected\nC. The volume of data available for analysis\nD. The challenges associated with data storage and analysis"], "outputs": ["C", "B", "C", "C", "D", "D", "ABD", "B", "C", "C", "BCD", "BCD"], "input": "R Markdown\nWe've spent a lot of time getting R and RStudio working, learning about projects and version control. You are practically an expert of this. There is one last major functionality of our slash R Studio that we would be remiss to not include in your introduction to R; Markdown. R Markdown is a way of creating fully reproducible documents in which both text and code can be combined. In fact, this lessons are written using R Markdown. That's how we make things like bullet lists, bolded and italicized text, in line links and run inline r code. By the end of this lesson, you should be able to do each of those things too and more. Despite these documents all starting as plain text, you can render them into HTML pages, or PDF, or Word documents or slides, the symbols you use to signal, for example, bold or italics is compatible with all of those formats. One of the main benefits is the reproducibility of using R Markdown. Since you can easily combine text and code chunks in one document, you can easily integrate introductions, hypotheses, your code that you are running, the results of that code, and your conclusions all in one document. Sharing what you did, why you did it, and how it turned out becomes so simple, and that person you share it with can rerun your code and get the exact same answers you got. That's what we mean about reproducibility. But also, sometimes you will be working on a project that takes many weeks to complete. You want to be able to see what you did a long time ago and perhaps be reminded exactly why you were doing this. And you can see exactly what you ran and the results of that code, and R Markdown documents allow you to do that. Another major benefit to R markdown is that since it is plain texts, it works very well with version control systems. It is easy to track what character changes occur between commits unlike other formats that are in plain text. For example, in one version of this lesson, I may have forgotten to bold\" this\" word. When I catch my mistake, I can make the plain text changes to signal I would like that word bolded, and in the commit, you can see the exact character changes that occurred to now make the word bold. Another selfish benefit of R Markdown is how easy it is to use. Like everything in R, this extended functionality comes from an R package: rmarkdown. All you need to do to install it is run install.packages R Markdown, and that's it. You are ready to go. To create an R Markdown document in Rstudio, go to File, New File, R Markdown. You will be presented with this window. I've filled in a title and an author and switch the output format to a PDF. Explore on this window and the tabs along the left to see all the different formats that you can output too. When you are done, click OK, and a new window should open with a little explanation on R Markdown files. There are three main sections of an R Markdown document. The first is the header at the top bounded by the three dashes. This is where you can specify details like the title, your name, the date, and what kind of document you want to output. If you filled in the blanks in the window earlier, these should be filled out for you. Also on this page, you can see text sections, for example, one section starts with ## R Markdown. We'll talk more about what this means in a second, but this section will render as text when you produce the PDF of this file, and all of the formatting you will learn generally applies to this section. Finally, you will see code chunks. These are bounded by the triple back texts. These are pieces of our code chunks that you can run right from within your document, and the output of this code will be included in the PDF when you create it. The easiest way to see how each of these sections behave is to produce the PDF. When you are done with a document in R Markdown, you are set to knit your plain text and code into your final document. To do so, click on the Knit button along the top of the source panel. When you do so, it will prompt you to save the document as an RMD file, do so. You should see a document like this one. So, here you can see that the content of a header was rendered into a title, followed by your name and the date. The text chunks produced a section header called R Markdown, which is valid by two paragraphs of text. Following this, you can see the R code, summary (cars) which is importantly followed by the output of running that code. Further down, you will see code that ran to produce a plot, and then that plot. This is one of the huge benefits of R Markdown, rendering the results to code inline. Go back to the R Markdown file that produced this PDF and see if you can see how you signify you on text build it, and look at the word Knit and see what it is surrounded by. At this point, I hope we've convinced you that R Markdown is a useful way to keep your code/data, and have set you up to be able to play around with it. To get you started, we'll practice some of the formatting that is inherent to R Markdown documents. To start, let's look at bolding and italicizing text. To bold text, you surround it by two asterisks on either side. Similarly, to italicize text, you surround the word with a single asterisk on either side. We've also seen from the default document that you can make section headers. To do this, you put a series of hash marks. The number of hash marks determines what level of heading it is. One hash is the highest level and will make the largest text. Two hashes is the next highest level and so on. Play around with this formatting and make a series of headers. The other thing we've seen so far is code chunks. To make an R code chunk, you can type the three back ticks, followed by the curly brackets surrounding a lowercase r. Put your code on a new line and end the chunk with three back ticks. Thankfully, RStudio recognize you'd be doing this a lot and there are shortcuts. Namely, Control, Alt, I for Windows. Or command, Option, I for max. Additionally, along the top of the source quadrant, there is the insert button that will also produce an empty code chunk. Try making an empty code chunk. Inside it, type the code print, Hello world. When you need your document, you will see this code chunk and the admittedly simplistic output of that chunk. If you aren't ready to knit your document yet but wanted to see the output of your code, select the line of code you want to run and use Control Enter, or hit the Run button along the top of your source window. The text Hello world should be outputted in your console window. If you have multiple lines of code in a chunk and you want to run them all in one go, you can run the entire chunk by using Control, Shift, Enter, or hitting the green arrow button on the right side of the chunk, or going to the Run menu and selecting Run Current Chunk. One final thing we will go into detail on is making bulleted lists, like the one at the top of this lesson. Lists are easily created by proceeding each perspective bullet point by a single dash, followed by a space. Importantly, at the end of each bullets line, end with two spaces. This is a quirk of R Markdown that will cause spacing problems if not included. This is a great starting point, and there is so much more you can do with R Markdown. Thankfully, RStudio developers have produced an R Markdown cheat sheet that we urge you to go check out and see everything you can do with R Markdown. The sky is the limit. In this lesson, we've delved into R Markdown, starting with what it is and why you might want to use it. We hopefully got you started with R Markdown, first by installing it, and then by generating and knitting our first R Markdown document. We then looked at some of the various formatting options available to you in practice generating code and running it within the RStudio interface.\n\nTypes of Data Science Questions\nIn this lesson, we're going to be a little more conceptual and look at some of the types of analyses data scientists employ to answer questions in data science. There are, broadly speaking, six categories in which data analysis fall. In the approximate order of difficulty, they are, descriptive, exploratory, inferential, predictive, causal, and mechanistic. Let's explore the goals of each of these types and look at some examples of each analysis. To start, let's look at descriptive data analysis. The goal of descriptive analysis is to describe or summarize a set of data. Whenever you get a new data set to examine, this is usually the first kind of analysis you will perform. Descriptive analysis will generate simple summaries about the samples and their measurements. You may be familiar with common descriptive statistics, including measures of central tendency e.g, mean, median, mode. Or measures of variability e.g, range, standard deviations, or variance. This type of analysis is aimed at summarizing your sample, not for generalizing the results of the analysis to a larger population, or trying to make conclusions. Description of data is separated from making interpretations. Generalizations and interpretations require additional statistical steps. Some examples of purely descriptive analysis can be seen in censuses. Here the government collects a series of measurements on all of the country's citizens, which can then be summarized. Here you are being shown the age distribution in the US, stratified by sex. The goal of this is just to describe the distribution. There is no inferences about what this means or predictions on how the data might trend in the future. It is just to show you a summary of the data collected. The goal of exploratory analysis is to examine or explore the data and find relationships that weren't previously known. Exploratory analyzes explore how different measures might be related to each other but do not confirm that relationship is causative. You've probably heard the phrase correlation does not imply causation, and exploratory analysis lie at the root of this saying. Just because you observed a relationship between two variables during exploratory analysis, it does not mean that one necessarily causes the other. Because of this, exploratory analysis, while useful for discovering new connections, should not be the final say in answering a question. It can allow you to formulate hypotheses and drive the design of future studies and data collection. But exploratory analysis alone should never be used as the final say on why or how data might be related to each other. Going back to the census example from above, rather than just summarizing the data points within a single variable, we can look at how two or more variables might be related to each other. In this plot, we can see the percent of the work force that is made up of women in various sectors, and how that has changed between 2000 and 2016. Exploring this data, we can see quite a few relationships. Looking just at the top row of the data, we can see that women make up a vast majority of nurses, and that it has slightly decreased in 16 years. While these are interesting relationships to note, the causes of these relationship is no apparent from this analysis. All exploratory analysis can tell us is that a relationship exist, not the cause. The goal of inferential analysis is to use a relatively small sample of data to or infer say something about the population at large. Inferential analysis is commonly the goal of statistical modelling. Where you have a small amount of information to extrapolate and generalise that information to a larger group. inferential analysis typically involves using the data you have to estimate that value in the population, and then give a measure of uncertainty about your estimate. Since you are moving from a small amount of data and trying to generalize to a larger population, your ability to accurately infer information about the larger population depends heavily on your sampling scheme. If the data you collect is not from a representative sample of the population, the generalizations you infer won't be accurate for the population. Unlike in our previous examples, we shouldn't be using census data in inferential analysis. A census already collects information on functionally the entire population, there is nobody left to infer to. And inferring data from the US census to another country would not be a good idea, because they US isn't necessarily representative of another country that we are trying to infer knowledge about. Instead, a better example of inferential analysis is a study in which a subset of the US population wasn't safe, for their life expectancy given the level of air pollution they experienced. This study uses the data they collected from a sample of the US population, to infer how air pollution might be impacting life expectancy in the entire US. The goal of predictive analysis is to use current data to make predictions about future data. Essentially, you are using current and historical data to find patterns, and predict the likelihood of future outcomes. Like in inferential analysis, your accuracy and predictions is dependent on measuring the right variables. If you aren't measuring the right variables to predict an outcome, your predictions aren't going to be accurate. Additionally, there are many ways to build up prediction models with some being better or worse for specific cases. But in general, having more data and a simple model, generally performs well at predicting future outcomes. All this been said, much like an exploratory analysis, just because one variable one variable may predict another, it does not mean that one causes the other. You are just capitalizing on this observed relationship to predict this second variable. A common saying is that prediction is hard, especially about the future. There aren't easy ways to gauge how well you are going to predict an event until that event has come to pass. So evaluating different approaches or models is a challenge. We spend a lot of time trying to predict things. The upcoming weather. The outcomes of sports events. And in the example we'll explore here, the outcomes of elections. We've previously mentioned Nate Silver of FiveThirtyEight, where they try and predict the outcomes of US elections, and sports matches too. Using historical polling data and trends in current polling, FiveThirtyEight builds models to predict the outcomes in the next US presidential vote, and has been fairly accurate at doing so. FiveThirtyEight's models accurately predicted the 2008 and 2012 elections, and was widely considered an outlier in the 2016 US elections, as it was one of the few models to suggest Donald Trump at having a chance of winning. The caveat to a lot of the analyses we've looked at so far is we can only see correlations and can't get at the cause of the relationships we observe. Causal analysis fills that gap. The goal of causal analysis is to see what happens to one variable when we manipulate another variable, looking at the cause and effect of the relationship. Generally, causal analysis are fairly complicated to do with observed data alone. There will always be questions as to whether are these correlation driving your conclusions, or that the assumptions underlying your analysis are valid. More often, causal analysis are applied to the results of randomized studies that were designed to identify causation. Causal analysis is often considered the gold standard in data analysis, and is seen frequently in scientific studies where scientists are trying to identify the cause of a phenomenon. But often getting appropriate data for doing a causal analysis is a challenge. One thing to note about causal analysis is that the data is usually analyzed in aggregate and observed relationships are usually average effects. So, while on average, giving a certain population a drug may alleviate the symptoms of a disease, this causal relationship may not hold true for every single affected individual. As we've said, many scientific studies allow for causal analysis. Randomized controlled trials for drugs are a prime example of this. For example, one randomized control trial examine the effect of a new drug on a treating infants with spinal muscular atrophy. Comparing a sample of infants receiving the drug versus a sample receiving a mock control. They measure various clinical outcomes in the babies and look at how the drug affects the outcomes. Mechanistic analysis are not nearly as commonly used as the previous analysis. The goal of mechanistic analysis is to understand the exact changes in variables that lead to exact changes in other variables. These analyses are exceedingly hard to use to infer much, except in simple situations or in those that are nicely modeled by deterministic equations. Given this description, it might be clear to see how mechanistic analyses are most commonly applied to physical or engineering sciences, biological sciences. For example, are far too noisy of datasets to use mechanistic analysis. Often, when these analyses are applied, the only noise in the data is measurement error, which can be accounted for. You can generally find examples of mechanistic analysis in material science experiments. Here, we have a study on biocomposites, essentially making biodegradable plastics that was examining how biocarbon particle size, functional polymer type, and concentration affected mechanical properties of the resulting plastic. They are able to do mechanistic analysis through a careful balance of controlling and manipulating variables with very accurate measures of both those variables and the desired outcome. In this lesson, we've covered the various types of data analysis, their goals. And looked at a few examples of each to demonstrate what each analysis is capable of, and importantly, what it is not.\n\nExperimental Design\nNow that we've looked at the different types of data science questions, we are going to spend some time looking at experimental design concepts. As a data scientist, you are a scientist as such. We need to have the ability to design proper experiments to best answer your data science questions. Experimental design is organizing and experiments. So, that you have the correct data and enough of it to clearly and effectively answer your data science question. This process involves, clearly formulating your questions in advance of any data collection, designing the best setup possible to gather the data to answer your question, identifying problems or sources of air in your design, and only then collecting the appropriate data. Going into an analysis, you need plan in advance of what you're going to do and how you are going to analyze the data. If you do the wrong analysis, you can come to the wrong conclusions. We've seen many examples of this exact scenario play out in the scientific community over the years. There's an entire website, retraction watch dedicated to identifying papers that have been retracted or removed from the literature as a result of poor scientific practices, and sometimes those poor practices are a result of poor experimental design and analysis. Occasionally, these erroneous conclusions can have sweeping effects particularly in the field of human health. For example, here we have a paper that was trying to predict the effects of a person's genome on their response to different chemotherapies to guide which patient receives which drugs to best treat their cancer. As you can see, this paper was retracted over four years after it was initially published. In that time, this data which was later shown to have numerous problems in their setup and cleaning, was cited in nearly 450 other papers that may have used these erroneous results to bolster their own research plans. On top of this, this wrongly analyzed data was used in clinical trials to determine cancer patient treatment plans. When the stakes are this high, experimental design is paramount. There are a lot of concepts and terms inherent to experimental design. Let's go over some of these now. Independent variable AKA factor, is the variable that the experimenter manipulates. It does not depend on other variables being measured, often displayed on the x-axis. Dependent variables are those that are expected to change as a result of changes in the independent variable, often displayed on the y-axis. So, that changes the in x, the independent variable effect changes in y. So, when you are designing an experiment, you have to decide what variables you will measure, and which you will manipulate to effect changes and other measured variables. Additionally, you must develop your hypothesis. Essentially an educated guess as to the relationship between your variables and the outcome of your experiment. Let's do an example experiment now, let say for example that I have a hypothesis that a shoe size increases, literacy also increases. In this case designing my experiment, I will use a measure of literacy eg, reading fluency as my variable that depends on an individual's shoe size. To answer this question, I will design an experiment in which I measure this shoe size and literacy level of 100 individuals. Sample size is the number of experimental subjects you will include in your experiment. There are ways to pick an optimal sample size that you will cover in later courses. Before I collect my data though, I need to consider if there are problems with this experiment that might cause an erroneous result. In this case, my experiment may be fatally flawed by a confounder. A confounder is an extraneous variable that may affect the relationship between the dependent and independent variables. In our example since age effects for size and literacy is affected by age. If we see any relationship between shoe size and literacy, the relationship may actually be due to age, ages confounding our experimental design. To control for this, we can make sure we also measure the age of each individual. So, that we can take into account the effects of age on literacy, and other way we could control for ages effect on literacy would be to fix the age of all participants. If everyone we study is the same age, then we have removed the possible effect of age on literacy. In other experimental design paradigms, a control group may be appropriate. This is when you have a group of experimental subjects that are not manipulated. So, if you were studying the effect of a drug on survival, you would have a group that received the drug, treatment and a group that did not control. This way, you can compare the effects of the drug and the treatment versus control group. In these study designs, there are strategies we can use to control for confounding effects. One, we can blind the subjects to their assigned treatment group. Sometimes, when a subject knows that they are in the treatment group eg, receiving the experimental drug, they can feel better not from the drug itself but from knowing they are receiving treatment. This is known as the possible effect. To combat this, often participants are blinded to the treatment group they are in. This is usually achieved by giving the control group and lock treatment eg, given a sugar pill they are told is the drug. In this way, if the possible effect is causing a problem with your experiment, both groups should experience it equally, and this strategy is at the heart of many of these studies spreading any possible confounding effects equally across the groups being compared. For example, if you think age is a possible confounding effect, making sure that both groups have similar ages and age ranges will help to mitigate any effect age may be having on your dependent variable. The effect of age is equal between your two groups. This balancing of confounders is often achieved by randomization. Generally, we don't know what will be a confounder beforehand to help lessen the risk of accidentally biasing one group to be enriched for a confounder. You can randomly assign individuals to each of your groups. This means that any potential confounding variables should be distributed between each group roughly equally, to help eliminate/reduce systematic errors. There is one final concept of experimental design that we need to cover in this lesson and that is replication. Replication is pretty much what it sounds like repeating an experiment with different experimental subjects. As single experiments results may have occurred by chance. A confounder was unevenly distributed across your groups. There was a systematic error in the data collection. There were some outliers, etcetera. However, if you can repeat the experiment and collect a whole new set of data and still come to the same conclusion, your study is much stronger. Also at the heart of replication is that it allows you to measure the variability of your data more accurately, which allows you to better assess whether any differences you see in your data are significant. Once you've collected and analyzed your data, one of the next steps of being a good citizen scientist is to share your data and code for analysis. Now that you have a GitHub account and we've shown you how to keep your version control data and analyses on GitHub, this is a great place to share your code. In fact, hosted on GitHub, our group, the leek group has developed a guide that has great advice for how to best share data. One of the many things often reported in experiments as a value called the p-value. This is a value that tells you the probability that the results of your experiment were observed by chance. This is a very important concept in statistics that we won't be covering in depth here. If you want to know more, check out the YouTube video linked which explains more about p-values. What you need to look out for this when you manipulate p-values towards your own end, often when your p-value is less than 0.05. In other words, there is a five percent chance that the differences you saw were observed by chance. A result is considered significant. But if you do 20 tests by chance, you would expect one of the 20 that is five percent to be significant. In the age of big data, testing 20 hypotheses is a very easy proposition, and this is where the term p-hacking comes from. This is when you exhaustively search a dataset to find patterns and correlations that appear statistically significant by virtue of the sheer number of tests you have performed. These spurious correlations can be reported as significant and if you perform enough tests, you can find a dataset and analysis that will show you what you wanted to see. Check out this 538 activity, where you can manipulate unfiltered data and perform a series of tests such that you can get the data to find whatever relationship you want. XKCD mocks this concept in a comic testing the link between jelly beans and acne. Clearly there is no link there. But if you test enough jelly bean colors eventually, one of them will be correlated with acne at p-value less than 0.05. In this lesson, we covered what experimental design is and why good experimental design matters. We then looked in depth to the principles of experimental design and define some of the common terms you need to consider when designing an experiment. Next, we determined a bit to see how you should share your data and code for analysis, and finally we looked at the dangers of p-hacking and manipulating data to achieve significance.\n\nBig Data\nA term you may have heard of before this course is Big Data. There have always been large datasets, but it seems like lately, this has become a pasword in data science. What does it mean? We talked a little about big data in the very first lecture of this course. As the name suggests, big data are very large datasets. We previously discussed three qualities that are commonly attributed to big datasets; volume, velocity, variety. From these three adjectives, we can see that big data involves large datasets of diverse data types that are being generated very rapidly. But none of these qualities seem particularly new. Why has the concept of Big Data been so recently popularized? In part, as technology in data storage has evolved to be able to hold larger and larger datasets. The definition of \"big\" has evolved too. Also, our ability to collect and record data has improved with time such that the speed with which data is collected his unprecedented. Finally, what is considered data has evolved, so that there is now more than ever. Companies have recognized the benefits to collecting different information, and the rise of the internet and technology have allowed different and varied datasets to be more easily collected and available for analysis. One of the main shifts in data science has been moving from structured datasets to tackling unstructured data. Structured data is what you traditionally might think of data, long tables, spreadsheets, or databases, with columns and rows of information that you can sum or average or analyze, however you like within those confines. Unfortunately, this is rarely how data is presented to you in this day and age. The datasets we commonly encounter are much messier and it is our job to extract the information we want and corralled into something tidy and structured. With the digital age and the advance of the Internet, many pieces of information that we're in traditionally collected were suddenly able to be translated into a format that a computer could record, store, search and analyze. Once this was appreciated, there was a proliferation of this unstructured data being collected from all of our digital interactions, emails, Facebook and other social media interactions, text messages, shopping habits, smartphones and their GPS tracking websites you visit. How long you are on that website and what you look at, CCTV cameras and other video sources et cetera. The amount of data and the various sources that can record and transmit data has exploded. It is because of this explosion in the volume, velocity and variety of data that big data has become so salient a concept. These datasets are now so large and complex that we need new tools and approaches to make the most of them. As you can guess, given the variety of data types and sources, very rarely as the data stored in a neat, ordered spreadsheet, that traditional methods for cleaning and analysis can be applied to. Given some of the qualities of big data above, you can already start seeing some of the challenges that may be associated with working with big data. For one, it is big. There was a lot of raw data that you need to be able to store and analyze. Second, it is constantly changing and updating. By the time you finish your analysis, there is even more new data you could incorporate into your analysis. Every second you are analyzing, is another second of data you haven't used. Third, the variety can be overwhelming. There are so many sources of information that it can sometimes be difficult to determine what source of data may be best suited to answer your data science question. Finally, it is messy. You don't have neat data tables to quickly analyze. You have messy data. Before you can start looking for answers, you need to turn your unstructured data into a format that you can analyze. So, with all of these challenges, why don't we just stick to analyzing smaller, more manageable, curated datasets and arriving at our answers that way? Sometimes questions are best addressed using these smaller datasets, but many questions benefit from having lots and lots of data and if there is some messiness or inaccuracies in this data. The sheer volume of it negates the effect of these small errors. So, we are able to get closer to the truth even with these messier datasets. Additionally, when you have data that is constantly updating, while this can be a challenge to analyze, the ability to have real-time, up-to-date information allows you to do analyses that are accurate to the current state and make on the spot, rapid, informed predictions and decisions. One of the benefits of having all these new sources of information is that questions that weren't previously able to be answered due to lack of information. Suddenly have many more sources to glean information from and new connections and discoveries are now able to be made. Questions that previously were inaccessible now have newer, unconventional data sources that may allow you to answer these formerly unfeasible questions. Another benefit to using big data is that, it can identify hidden correlations. Since we can collect data on a myriad of qualities on any one subject, we can look for qualities that may not be obviously related to our outcome variable, but the big data can identify a correlation there. Instead of trying to understand precisely why an engine breaks down or why a drug side effect disappears, researchers can instead collect and analyze massive quantities of information about such events and everything that is associated with them, looking for patterns that might help predict future occurrences. Big data helps answer what? Not why? Often that's good enough. Big data has now made it possible to collect vast amounts of data, very rapidly from a variety of sources and improvements in technology have made it cheaper to collect, store and analyze. But the question remains, how much of this data explosion is useful for answering questions you care about? Regardless of the size of the data, you need the right data to answer a question. A famous statistician, John Tukey, said in 1986, \"The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.\" Essentially, any given dataset may not be suited for your question, even if you really wanted it to and big data does not fixed this. Even the largest datasets around might not be big enough to be able to answer your question if it's not the right data. In this lesson, we went over some qualities that characterize big data, volume, velocity and variety. We compared structured and unstructured data and examined some of the new sources of unstructured data. Then, we turn to looking at the challenges and benefits of working with these big datasets. Finally, we came back to the idea that data science is question-driven science and even the largest of datasets may not be appropriate for your case.\n", "source": "coursera_a", "evaluation": "exam"}
{"instructions": ["Question 1. What is NOT the primary purpose of random sampling in data analysis? Select all that apply.\nA. To ensure that every possible type of sample has an equal chance of being chosen\nB. To reduce the cost and time associated with data analysis\nC. To eliminate the need for a large sample size\nD. To make data easier to organize and read", "Question 2. Which of the following factors can compromise data integrity? Select all that apply.\nA. Data replication\nB. Data transfer\nC. Data manipulation\nD. Human error", "Question 3. What is the  NOT the main reason for using a sample size instead of analyzing an entire population of data? Select all that apply.\nA. Analyzing an entire population is always more accurate\nB. Sample size is less time-consuming and cost-effective\nC. Sample size is more likely to produce statistically significant results\nD. Sample size eliminates the risk of sampling bias", "Question 4.  Which of the following conditions are necessary to ensure data integrity? Select all that apply.\nA. Statistical power\nB. Completeness\nC. Accuracy\nD. Privacy", "Question 5. What is NOT the purpose of calculating the margin of error in a study? Select all that apply.\nA. To determine the maximum amount that the sample results are expected to differ from those of the actual population\nB. To ensure that the sample size is large enough to produce statistically significant results\nC. To calculate the confidence level of the study\nD. To eliminate sampling bias in the study", "Question 6. In data analysis, what is the main benefit of having a high confidence level?\nA. It ensures that the sample size is large enough\nB. It guarantees that the results are statistically significant\nC. It increases the probability that the sample accurately reflects the greater population\nD. It reduces the margin of error", "A data analyst wants to find out how many people in Utah have swimming pools. It\u2019s unlikely that they can survey every Utah resident. Instead, they survey enough people to be representative of the population. This describes what data analytics concept?\nA. Margin of error\nB. Statistical significance\nC. Sample\nD. Confidence level", "Question 8. If an analyst lacks the necessary data to achieve a business goal, what should be their next course of action? (Select all that apply)\nA. Proceed with the analysis using less trustworthy data sources.\nB. Carry out the analysis by identifying and employing surrogate data from different datasets.\nC. Generate and utilize assumed data that is consistent with the projected analysis.\nD. Collect pertinent data on a small scale and ask for an extension to acquire more comprehensive data.", "Question 9. Which of the following are limitations that might lead to insufficient data? Select all that apply.\nA. Duplicate data\nB. Data from a single source\nC. Outdated data\nD. Data that updates continually", "Question 10. Which of the following factors can lead to sampling bias? Select all that apply.\nA. A small sample size\nB. Using data from a single source\nC. A sample that is not representative of the population as a whole\nD. Random sampling from large scale data", "Question 11. In the context of data analysis, what does a low margin of error indicate?\nA. The sample size is too small\nB. The results of the study are not statistically significant\nC. The sample results are more likely to be close to the actual population results\nD. The confidence level is too high", "Question 12. A research team runs an experiment to determine if a new security system is more effective than the previous version. What type of results are required for the experiment to be statistically significant?\nA. Results that are real and not caused by random chance\nB. Results that are hypothetical and in need of more testing\nC. Results that are inaccurate and should be ignored\nD. Results that are unlikely to occur again", "Question 13. In a survey about a new cleaning product, 75% of respondents report they would buy the product again. The margin of error for the survey is 5%. Based on the margin of error, what percentage range reflects the population\u2019s true response?\nA. Between 70% and 80%\nB. Between 75% and 80%\nC. Between 73% and 78%\nD. Between 70% and 75%", "Question 14. A car manufacturer wants to learn more about the brand preferences of electric car owners. There are millions of electric car owners in the world. Who should the company survey?\nA. A sample of car owners who most recently bought an electric car\nB. A sample of all electric car owners\nC. A sample of car owners who have owned more than one electric car\nD. The entire population of electric car owners"], "outputs": ["BCD", "ABCD", "ACD", "BC", "BCD", "C", "C", "BD", "BCD", "ABC", "C", "A", "A", "B"], "input": "Introduction to focus on integrity\nHi! Good to see you! My name is Sally, and I'm here to teach you all about processing data. I'm a measurement and analytical lead at Google. My job is to help advertising agencies and companies measure success and analyze their data, so I get to meet with lots of different people to show them how data analysis helps with their advertising. Speaking of analysis, you did great earlier learning how to gather and organize data for analysis. It's definitely an important step in the data analysis process, so well done! Now let's talk about how to make sure that your organized data is complete and accurate. Clean data is the key to making sure your data has integrity before you analyze it. We'll show you how to make sure your data is clean and tidy. Cleaning and processing data is one part of the overall data analysis process. As a quick reminder, that process is Ask, Prepare, Process, Analyze, Share, and Act. Which means it's time for us to explore the Process phase, and I'm here to guide you the whole way. I'm very familiar with where you are right now. I'd never heard of data analytics until I went through a program similar to this one. Once I started making progress, I realized how much I enjoyed data analytics and the doors it could open. And now I'm excited to help you open those same doors! One thing I realized as I worked for different companies, is that clean data is important in every industry. For example, I learned early in my career to be on the lookout for duplicate data, a common problem that analysts come across when cleaning. I used to work for a company that had different types of subscriptions. In our data set, each user would have a new row for each subscription type they bought, which meant users would show up more than once in my data. So if I had counted the number of users in a table without accounting for duplicates like this, I would have counted some users twice instead of once. As a result, my analysis would have been wrong, which would have led to problems in my reports and for the stakeholders relying on my analysis. Imagine if I told the CEO that we had twice as many customers as we actually did!? That's why clean data is so important. So the first step in processing data is learning about data integrity. You will find out what data integrity is and why it is important to maintain it throughout the data analysis process. Sometimes you might not even have the data that you need, so you'll have to create it yourself. This will help you learn how sample size and random sampling can save you time and effort. Testing data is another important step to take when processing data. We'll share some guidance on how to test data before your analysis officially begins. Just like you'd clean your clothes and your dishes in everyday life, analysts clean their data all the time, too. The importance of clean data will definitely be a focus here. You'll learn data cleaning techniques for all scenarios, along with some pitfalls to watch out for as you clean. You'll explore data cleaning in both spreadsheets and databases, building on what you've already learned about spreadsheets. We'll talk more about SQL and how you can use it to clean data and do other useful things, too. When analysts clean their data, they do a lot more than a spot check to make sure it was done correctly. You'll learn ways to verify and report your cleaning results. This includes documenting your cleaning process, which has lots of benefits that we'll explore. It's important to remember that processing data is just one of the tasks you'll complete as a data analyst. Actually, your skills with cleaning data might just end up being something you highlight on your resume when you start job hunting. Speaking of resumes, you'll be able to start thinking about how to build your own from the perspective of a data analyst. Once you're done here, you'll have a strong appreciation for clean data and how important it is in the data analysis process. So let's get started!\n\nWhy data integrity is important\nWelcome back. In this video, we're going to discuss data integrity and some risks you might run into as a data analyst. A strong analysis depends on the integrity of the data. If the data you're using is compromised in any way, your analysis won't be as strong as it should be. Data integrity is the accuracy, completeness, consistency, and trustworthiness of data throughout its lifecycle. That might sound like a lot of qualities for the data to live up to. But trust me, it's worth it to check for them all before proceeding with your analysis. Otherwise, your analysis could be wrong. Not because you did something wrong, but because the data you were working with was wrong to begin with. When data integrity is low, it can cause anything from the loss of a single pixel in an image to an incorrect medical decision. In some cases, one missing piece can make all of your data useless. Data integrity can be compromised in lots of different ways. There's a chance data can be compromised every time it's replicated, transferred, or manipulated in any way. Data replication is the process of storing data in multiple locations. If you're replicating data at different times in different places, there's a chance your data will be out of sync. This data lacks integrity because different people might not be using the same data for their findings, which can cause inconsistencies. There's also the issue of data transfer, which is the process of copying data from a storage device to memory, or from one computer to another. If your data transfer is interrupted, you might end up with an incomplete data set, which might not be useful for your needs. The data manipulation process involves changing the data to make it more organized and easier to read. Data manipulation is meant to make the data analysis process more efficient, but an error during the process can compromise the efficiency. Finally, data can also be compromised through human error, viruses, malware, hacking, and system failures, which can all lead to even more headaches. I'll stop there. That's enough potentially bad news to digest. Let's move on to some potentially good news. In a lot of companies, the data warehouse or data engineering team takes care of ensuring data integrity. Coming up, we'll learn about checking data integrity as a data analyst. But rest assured, someone else will usually have your back too. After you've found out what data you're working with, it's important to double-check that your data is complete and valid before analysis. This will help ensure that your analysis and eventual conclusions are accurate. Checking data integrity is a vital step in processing your data to get it ready for analysis, whether you or someone else at your company is doing it. Coming up, you'll learn even more about data integrity. See you soon!\n\nBalancing objectives with data integrity\nHey there, it's good to remember to check for data integrity. It's also important to check that the data you use aligns with the business objective. This adds another layer to the maintenance of data integrity because the data you're using might have limitations that you'll need to deal with. The process of matching data to business objectives can actually be pretty straightforward. Here's a quick example. Let's say you're an analyst for a business that produces and sells auto parts.\nIf you need to address a question about the revenue generated by the sale of a certain part, then you'd pull up the revenue table from the data set.\nIf the question is about customer reviews, then you'd pull up the reviews table to analyze the average ratings. But before digging into any analysis, you need to consider a few limitations that might affect it. If the data hasn't been cleaned properly, then you won't be able to use it yet. You would need to wait until a thorough cleaning has been done. Now, let's say you're trying to find how much an average customer spends. You notice the same customer's data showing up in more than one row. This is called duplicate data. To fix this, you might need to change the format of the data, or you might need to change the way you calculate the average. Otherwise, it will seem like the data is for two different people, and you'll be stuck with misleading calculations. You might also realize there's not enough data to complete an accurate analysis. Maybe you only have a couple of months' worth of sales data. There's slim chance you could wait for more data, but it's more likely that you'll have to change your process or find alternate sources of data while still meeting your objective. I like to think of a data set like a picture. Take this picture. What are we looking at?\nUnless you're an expert traveler or know the area, it may be hard to pick out from just these two images.\nVisually, it's very clear when we aren't seeing the whole picture. When you get the complete picture, you realize... you're in London!\nWith incomplete data, it's hard to see the whole picture to get a real sense of what is going on. We sometimes trust data because if it comes to us in rows and columns, it seems like everything we need is there if we just query it. But that's just not true. I remember a time when I found out I didn't have enough data and had to find a solution.\nI was working for an online retail company and was asked to figure out how to shorten customer purchase to delivery time. Faster delivery times usually lead to happier customers. When I checked the data set, I found very limited tracking information. We were missing some pretty key details. So the data engineers and I created new processes to track additional information, like the number of stops in a journey. Using this data, we reduced the time it took from purchase to delivery and saw an improvement in customer satisfaction. That felt pretty great! Learning how to deal with data issues while staying focused on your objective will help set you up for success in your career as a data analyst. And your path to success continues. Next step, you'll learn more about aligning data to objectives. Keep it up!\n\nDealing with insufficient data\nEvery analyst has been in a situation where there is insufficient data to help with their business objective. Considering how much data is generated every day, it may be hard to believe, but it's true. So let's discuss what you can do when you have insufficient data. We'll cover how to set limits for the scope of your analysis and what data you should include.\nAt one point, I was a data analyst at a support center. Every day, we received customer questions, which were logged in as support tickets.\nI was asked to forecast the number of support tickets coming in per month to figure out how many additional people we needed to hire. It was very important that we had sufficient data spanning back at least a couple of years because I had to account for year-to-year and seasonal changes. If I just had the current year's data available, I wouldn't have known that a spike in January is common and has to do with people asking for refunds after the holidays. Because I had sufficient data, I was able to suggest we hire more people in January to prepare. Challenges are bound to come up, but the good news is that once you know your business objective, you'll be able to recognize whether you have enough data. And if you don't, you'll be able to deal with it before you start your analysis. Now, let's check out some of those limitations you might come across and how you can handle different types of insufficient data.\nSay you're working in the tourism industry, and you need to find out which travel plans are searched most often. If you only use data from one booking site, you're limiting yourself to data from just one source. Other booking sites might show different trends that you would want to consider for your analysis. If a limitation like this impacts your analysis, you can stop and go back to your stakeholders to figure out a plan. If your data set keeps updating, that means the data is still incoming and might not be complete. So if there's a brand new tourist attraction that you're analyzing interest and attendance for, there's probably not enough data for you to determine trends. For example, you might want to wait a month to gather data. Or you can check in with the stakeholders and ask about adjusting the objective. For example, you might analyze trends from week to week instead of month to month. You could also base your analysis on trends over the past three months and say, \"Here's what attendance at the attraction for month four could look like.\"\nYou might not have enough data to know if this number is too low or too high. But you would tell stakeholders that it's your best estimate based on the data that you currently have. On the other hand, your data could be older and no longer be relevant. Outdated data about customer satisfaction won't include the most recent responses. So you'll be relying on the ratings for hotels or vacation rentals that might no longer be accurate. In this case, your best bet might be to find a new data set to work with. Data that's geographically-limited could also be unreliable. If your company is global, you wouldn't want to use data limited to travel in just one country. You would want a data set that includes all countries. So that's just a few of the most common limitations you'll come across and some ways you can address them. You can identify trends with the available data or wait for more data if time allows; you can talk with stakeholders and adjust your objective; or you can look for a new data set.\nThe need to take these steps will depend on your role in your company and possibly the needs of the wider industry. But learning how to deal with insufficient data is always a great way to set yourself up for success. Your data analyst powers are growing stronger. And just in time. After you learn more about limitations and solutions, you'll learn about statistical power, another fantastic tool for you to use. See you soon!\n\nThe importance of sample size\nOkay, earlier we talked about having the right kind of data to meet your business objective and the importance of having the right amount of data to make sure your analysis is as accurate as possible. You might remember that for data analysts, a population is all possible data values in a certain dataset. If you're able to use 100 percent of a population in your analysis, that's great. But sometimes collecting information about an entire population just isn't possible. It's too time-consuming or expensive. For example, let's say a global organization wants to know more about pet owners who have cats. You're tasked with finding out which kinds of toys cat owners in Canada prefer. But there's millions of cat owners in Canada, so getting data from all of them would be a huge challenge. Fear not! Allow me to introduce you to... sample size! When you use sample size or a sample, you use a part of a population that's representative of the population. The goal is to get enough information from a small group within a population to make predictions or conclusions about the whole population. The sample size helps ensure the degree to which you can be confident that your conclusions accurately represent the population. For the data on cat owners, a sample size might contain data about hundreds or thousands of people rather than millions. Using a sample for analysis is more cost-effective and takes less time. If done carefully and thoughtfully, you can get the same results using a sample size instead of trying to hunt down every single cat owner to find out their favorite cat toys. There is a potential downside, though. When you only use a small sample of a population, it can lead to uncertainty. You can't really be 100 percent sure that your statistics are a complete and accurate representation of the population. This leads to sampling bias, which we covered earlier in the program. Sampling bias is when a sample isn't representative of the population as a whole. This means some members of the population are being overrepresented or underrepresented. For example, if the survey used to collect data from cat owners only included people with smartphones, then cat owners who don't have a smartphone wouldn't be represented in the data. Using random sampling can help address some of those issues with sampling bias. Random sampling is a way of selecting a sample from a population so that every possible type of the sample has an equal chance of being chosen. Going back to our cat owners again, using a random sample of cat owners means cat owners of every type have an equal chance of being chosen. Cat owners who live in apartments in Ontario would have the same chance of being represented as those who live in houses in Alberta. As a data analyst, you'll find that creating sample sizes usually takes place before you even get to the data. But it's still good for you to know that the data you are going to analyze is representative of the population and works with your objective. It's also good to know what's coming up in your data journey. In the next video, you'll have an option to become even more comfortable with sample sizes. See you there.\n\nUsing statistical power\nHey, there. We've all probably dreamed of having a superpower at least once in our lives. I know I have. I'd love to be able to fly. But there's another superpower you might not have heard of: statistical power.\nStatistical power is the probability of getting meaningful results from a test. I'm guessing that's not a superpower any of you have dreamed about. Still, it's a pretty great data superpower. For data analysts, your projects might begin with the test or study. Hypothesis testing is a way to see if a survey or experiment has meaningful results. Here's an example. Let's say you work for a restaurant chain that's planning a marketing campaign for their new milkshakes. You need to test the ad on a group of customers before turning it into a nationwide ad campaign.\nIn the test, you want to check whether customers like or dislike the campaign. You also want to rule out any factors outside of the ad that might lead them to say they don't like it.\nUsing all your customers would be too time consuming and expensive. So, you'll need to figure out how many customers you'll need to show that the ad is effective. Fifty probably wouldn't be enough. Even if you randomly chose 50 customers, you might end up with customers who don't like milkshakes at all. And if that happens, you won't be able to measure the effectiveness of your ad in getting more milkshake orders since no one in the sample size would order them. That's why you need a larger sample size: so you can make sure you get a good number of all types of people for your test. Usually, the larger the sample size, the greater the chance you'll have statistically significant results with your test. And that's statistical power.\nIn this case, using as many customers as possible will show the actual differences between the groups who like or dislike the ad versus people whose decision wasn't based on the ad at all.\nThere are ways to accurately calculate statistical power, but we won't go into them here. You might need to calculate it on your own as a data analyst.\nFor now, you should know that statistical power is usually shown as a value out of one. So if your statistical power is 0.6, that's the same thing as saying 60%. In the milk shake ad test, if you found a statistical power of 60%, that means there's a 60% chance of you getting a statistically significant result on the ad's effectiveness.\n\"Statistically significant\" is a term that is used in statistics. If you want to learn more about the technical meaning, you can search online. But in basic terms, if a test is statistically significant, it means the results of the test are real and not an error caused by random chance.\nSo there's a 60% chance that the results of the milkshake ad test are reliable and real and a 40% chance that the result of the test is wrong.\nUsually, you need a statistical power of at least 0.8 or 80% to consider your results statistically significant.\nLet's check out one more scenario. We'll stick with milkshakes because, well, because I like milkshakes. Imagine you work for a restaurant chain that wants to launch a brand-new birthday cake flavored milkshake.\nThis milkshake will be more expensive to produce than your other milkshakes. Your company hopes that the buzz around the new flavor will bring in more customers and money to offset this cost. They want to test this out in a few restaurant locations first. So let's figure out how many locations you'd have to use to be confident in your results.\nFirst, you'd have to think about what might prevent you from getting statistically significant results. Are there restaurants running any other promotions that might bring in new customers? Do some restaurants have customers that always buy the newest item, no matter what it is? Do some location have construction that recently started, that would prevent customers from even going to the restaurant?\nTo get a higher statistical power, you'd have to consider all of these factors before you decide how many locations to include in your sample size for your study.\nYou want to make sure any effect is most likely due to the new milkshake flavor, not another factor.\nThe measurable effects would be an increase in sales or the number of customers at the locations in your sample size. That's it for now. Coming up, we'll explore sample sizes in more detail, so you can get a better idea of how they impact your tests and studies.\nIn the meantime, you've gotten to know a little bit more about milkshakes and superpowers. And of course, statistical power. Sadly, only statistical power can truly be useful for data analysts. Though putting on my cape and flying to grab a milkshake right now does sound pretty good.\n\nDetermine the best sample size\nGreat to see you again. In this video, we'll go into more detail about sample sizes and data integrity. If you've ever been to a store that hands out samples, you know it's one of life's little pleasures. For me, anyway! those small samples are also a very smart way for businesses to learn more about their products from customers without having to give everyone a free sample. A lot of organizations use sample size in a similar way. They take one part of something larger. In this case, a sample of a population. Sometimes they'll perform complex tests on their data to see if it meets their business objectives. We won't go into all the calculations needed to do this effectively. Instead, we'll focus on a \"big picture\" look at the process and what it involves. As a quick reminder, sample size is a part of a population that is representative of the population. For businesses, it's a very important tool. It can be both expensive and time-consuming to analyze an entire population of data. Using sample size usually makes the most sense and can still lead to valid and useful findings. There are handy calculators online that can help you find sample size. You need to input the confidence level, population size, and margin of error. We've talked about population size before. To build on that, we'll learn about confidence level and margin of error. Knowing about these concepts will help you understand why you need them to calculate sample size. The confidence level is the probability that your sample accurately reflects the greater population. You can think of it the same way as confidence in anything else. It's how strongly you feel that you can rely on something or someone. Having a 99 percent confidence level is ideal. But most industries hope for at least a 90 or 95 percent confidence level. Industries like pharmaceuticals usually want a confidence level that's as high as possible when they are using a sample size. This makes sense because they're testing medicines and need to be sure they work and are safe for everyone to use. For other studies, organizations might just need to know that the test or survey results have them heading in the right direction. For example, if a paint company is testing out new colors, a lower confidence level is okay. You also want to consider the margin of error for your study. You'll learn more about this soon, but it basically tells you how close your sample size results are to what your results would be if you use the entire population that your sample size represents. Think of it like this. Let's say that the principal of a middle school approaches you with a study about students' candy preferences. They need to know an appropriate sample size, and they need it now. The school has a student population of 500, and they're asking for a confidence level of 95 percent and a margin of error of 5 percent. We've set up a calculator in a spreadsheet, but you can also easily find this type of calculator by searching \"sample size calculator\" on the internet. Just like those calculators, our spreadsheet calculator doesn't show any of the more complex calculations for figuring out sample size. All we need to do is input the numbers for our population, confidence level, and margin of error. And when we type 500 for our population size, 95 for our confidence level percentage, 5 for our margin of error percentage, the result is about 218. That means for this study, an appropriate sample size would be 218. If we surveyed 218 students and found that 55 percent of them preferred chocolate, then we could be pretty confident that would be true of all 500 students. 218 is the minimum number of people we need to survey based on our criteria of a 95 percent confidence level and a 5 percent margin of error. In case you're wondering, the confidence level and margin of error don't have to add up to 100 percent. They're independent of each other. So let's say we change our margin of error from 5 percent to 3 percent. Then we find that our sample size would need to be larger, about 341 instead of 218, to make the results of the study more representative of the population. Feel free to practice with an online calculator. Knowing sample size and how to find it will help you when you work with data. We've got more useful knowledge coming your way, including learning about margin of error. See you soon!\n\nEvaluate the reliability of your data\nHey there! Earlier, we touched on margin of error without explaining it completely. Well, we're going to right that wrong in this video by explaining margin of error more. We'll even include an example of how to calculate it.\nAs a data analyst, it's important for you to figure out sample size and variables like confidence level and margin of error before running any kind of test or survey. It's the best way to make sure your results are objective, and it gives you a better chance of getting statistically significant results. But if you already know the sample size, like when you're given survey results to analyze, you can calculate the margin of error yourself. Then you'll have a better idea of how much of a difference there is between your sample and your population. We'll start at the beginning with a more complete definition. Margin of error is the maximum that the sample results are expected to differ from those of the actual population.\nLet's think about an example of margin of error.\nIt would be great to survey or test an entire population, but it's usually impossible or impractical to do this. So instead, we take a sample of the larger population.\nBased on the sample size, the resulting margin of error will tell us how different the results might be compared to the results if we had surveyed the entire population.\nMargin of error helps you understand how reliable the data from your hypothesis testing is.\nThe closer to zero the margin of error, the closer your results from your sample would match results from the overall population.\nFor example, let's say you completed a nationwide survey using a sample of the population. You asked people who work five-day workweeks whether they like the idea of a four-day workweek. So your survey tells you that 60% prefer a four-day workweek. The margin of error was 10%, which tells us that between 50 and 70% like the idea. So if we were to survey all five-day workers nationwide, between 50 and 70% would agree with our results.\nKeep in mind that our range is between 50 and 70%. That's because the margin of error is counted in both directions from the survey results of 60%. If you set up a 95% confidence level for your survey, there'll be a 95% chance that the entire population's responses will fall between 50 and 70% saying, yes, they want a four-day workweek.\nSince your margin of error overlaps with that 50% mark, you can't say for sure that the public likes the idea of a four-day workweek. In that case, you'd have to say your survey was inconclusive.\nNow, if you wanted a lower margin of error, say 5%, with a range between 55 and 65%, you could increase the sample size. But if you've already been given the sample size, you can calculate the margin of error yourself.\nThen you can decide yourself how much of a chance your results have of being statistically significant based on your margin of error. In general, the more people you include in your survey, the more likely your sample is representative of the entire population.\nDecreasing the confidence level would also have the same effect, but that would also make it less likely that your survey is accurate.\nSo to calculate margin of error, you need three things: population size, sample size, and confidence level.\nAnd just like with sample size, you can find lots of calculators online by searching \"margin of error calculator.\"\nBut we'll show you in a spreadsheet, just like we did when we calculated sample size.\nLets say you're running a study on the effectiveness of a new drug. You have a sample size of 500 participants whose condition affects 1% of the world's population. That's about 80 million people, which is the population for your study.\nSince it's a drug study, you need to have a confidence level of 99%. You also need a low margin of error. Let's calculate it. We'll put the numbers for population, confidence level, and sample size, in the appropriate spreadsheet cells. And our result is a margin of error of close to 6%, plus or minus. When the drug study is complete, you'd apply the margin of error to your results to determine how reliable your results might be.\nCalculators like this one in the spreadsheet are just one of the many tools you can use to ensure data integrity.\nAnd it's also good to remember that checking for data integrity and aligning the data with your objectives will put you in good shape to complete your analysis.\nKnowing about sample size, statistical power, margin of error, and other topics we've covered will help your analysis run smoothly. That's a lot of new concepts to take in. If you'd like to review them at any time, you can find them all in the glossary, or feel free to rewatch the video! Soon you'll explore the ins and outs of clean data. The data adventure keeps moving! I'm so glad you're moving along with it. You got this!\n", "source": "coursera_b", "evaluation": "exam"}
{"instructions": ["Question 1. What does the COUNTIF function do in a spreadsheet?\nA. Counts the number of cells that match a specified value\nB. Counts the number of cells that contain a specific character\nC. Returns the total value of cells that meet a certain condition\nD. Counts the number of times a value appears in a range of cells", "Question 2. What is the purpose of the TRIM function in a spreadsheet?\nA. To count the number of characters in a text string\nB. To remove leading, trailing, and repeated spaces in data\nC. To split a text string into separate cells\nD. To join multiple text strings into a single string", "Question 3. What does the VLOOKUP function do in a spreadsheet?\nA. Look up a cell that match a specified value\nB. Find out extra spaces from a text string\nC. Look up the value in a row to find a specified value\nD. Searches for a certain value in a column to return a corresponding piece of information", "Question 4. What is the purpose of conditional formatting in a spreadsheet?\nA. To change how cells appear when values meet specific conditions\nB. To count the number of characters in a text string\nC. To remove extra spaces from a text string\nD. To join multiple text strings into a single string", "Question 5. Describe the difference between a null and a zero in a dataset.\nA. A null signifies invalid data. A zero is missing data.\nB. A null indicates that a value does not exist. A zero is a numerical response.\nC. A null represents a value of zero. A zero represents an empty cell.\nD. A null represents a number with no significance. A zero represents the number zero.", "Question 6. What are the most common processes and procedures handled by data engineers? \nA. Giving data a reliable infrastructure\nB. Developing, maintaining, and testing systems\nC. Verifying results of data analysis\nD. Transforming data into a useful format for analysis", "Question 7. What are the most common processes and procedures handled by data warehousing specialists? Select all that apply.\nA. Ensuring data is properly cleaned\nB. Ensuring data is available\nC. Ensuring data is backed up to prevent loss\nD. Ensuring data is secure"], "outputs": ["AD", "B", "A", "A", "B", "ABD", "BCD"], "input": "Why data cleaning is important\nClean data is incredibly important for effective analysis. If a piece of data is entered into a spreadsheet or database incorrectly, or if it's repeated, or if a field is left blank, or if data formats are inconsistent, the result is dirty data. Small mistakes can lead to big consequences in the long run. I'll be completely honest with you, data cleaning is like brushing your teeth. It's something you should do and do properly because otherwise it can cause serious problems. For teeth, that might be cavities or gum disease. For data, that might be costing your company money, or an angry boss. But here's the good news. If you keep brushing twice a day, every day, it becomes a habit. Soon, you don't even have to think about it. It's the same with data. Trust me, it will make you look great when you take the time to clean up that dirty data. As a quick refresher, dirty data is incomplete, incorrect, or irrelevant to the problem you're trying to solve. It can't be used in a meaningful way, which makes analysis very difficult, if not impossible. On the other hand, clean data is complete, correct, and relevant to the problem you're trying to solve. This allows you to understand and analyze information and identify important patterns, connect related information, and draw useful conclusions. Then you can apply what you learn to make effective decisions. In some cases, you won't have to do a lot of work to clean data. For example, when you use internal data that's been verified and cared for by your company's data engineers and data warehouse team, it's more likely to be clean. Let's talk about some people you'll work with as a data analyst. Data engineers transform data into a useful format for analysis and give it a reliable infrastructure. This means they develop, maintain, and test databases, data processors and related systems. Data warehousing specialists develop processes and procedures to effectively store and organize data. They make sure that data is available, secure, and backed up to prevent loss. When you become a data analyst, you can learn a lot by working with the person who maintains your databases to learn about their systems. If data passes through the hands of a data engineer or a data warehousing specialist first, you know you're off to a good start on your project. There's a lot of great career opportunities as a data engineer or a data warehousing specialist. If this kind of work sounds interesting to you, maybe your career path will involve helping organizations save lots of time, effort, and money by making sure their data is sparkling clean. But even if you go in a different direction with your data analytics career and have the advantage of working with data engineers and warehousing specialists, you're still likely to have to clean your own data. It's important to remember: no dataset is perfect. It's always a good idea to examine and clean data before beginning analysis. Here's an example. Let's say you're working on a project where you need to figure out how many people use your company's software program. You have a spreadsheet that was created internally and verified by a data engineer and a data warehousing specialist. Check out the column labeled \"Username.\" It might seem logical that you can just scroll down and count the rows to figure out how many users you have.\nBut that won't work because one person sometimes has more than one username.\nMaybe they registered from different email addresses, or maybe they have a work and personal account. In situations like this, you would need to clean the data by eliminating any rows that are duplicates.\nOnce you've done that, there won't be any more duplicate entries. Then your spreadsheet is ready to be put to work. So far we've discussed working with internal data. But data cleaning becomes even more important when working with external data, especially if it comes from multiple sources. Let's say the software company from our example surveyed its customers to learn how satisfied they are with its software product. But when you review the survey data, you find that you have several nulls.\nA null is an indication that a value does not exist in a data set. Note that it's not the same as a zero. In the case of a survey, a null would mean the customers skipped that question. A zero would mean they provided zero as their response. To do your analysis, you would first need to clean this data. Step one would be to decide what to do with those nulls. You could either filter them out and communicate that you now have a smaller sample size, or you can keep them in and learn from the fact that the customers did not provide responses. There's lots of reasons why this could have happened. Maybe your survey questions weren't written as well as they could be. Maybe they were confusing or biased, something we learned about earlier. We've touched on the basics of cleaning internal and external data, but there's lots more to come. Soon, we'll learn about the common errors to be aware of to ensure your data is complete, correct, and relevant. See you soon!!\n\nRecognize and remedy dirty data\nHey, there. In this video, we'll focus on common issues associated with dirty data. These includes spelling and other texts errors, inconsistent labels, formats and field lane, missing data and duplicates. This will help you recognize problems quicker and give you the information you need to fix them when you encounter something similar during your own analysis. This is incredibly important in data analytics. Let's go back to our law office spreadsheet. As a quick refresher, we'll start by checking out the different types of dirty data it shows. Sometimes, someone might key in a piece of data incorrectly. Other times, they might not keep data formats consistent.\nIt's also common to leave a field blank.\nThat's also called a null, which we learned about earlier. If someone adds the same piece of data more than once, that creates a duplicate.\nLet's break that down. Then we'll learn about a few other types of dirty data and strategies for cleaning it. Misspellings, spelling variations, mixed up letters, inconsistent punctuation, and typos in general, happen when someone types in a piece of data incorrectly. As a data analyst, you'll also deal with different currencies. For example, one dataset could be in US dollars and another in euros, and you don't want to get them mixed up. We want to find these types of errors and fix them like this.\nYou'll learn more about this soon. Clean data depends largely on the data integrity rules that an organization follows, such as spelling and punctuation guidelines. For example, a beverage company might ask everyone working in its database to enter data about volume in fluid ounces instead of cups. It's great when an organization has rules like this in place. It really helps minimize the amount of data cleaning required, but it can't eliminate it completely. Like we discussed earlier, there's always the possibility of human error. The next type of dirty data our spreadsheet shows is inconsistent formatting. In this example, something that should be formatted as currency is shown as a percentage. Until this error is fixed, like this, the law office will have no idea how much money this customer paid for its services. We'll learn about different ways to solve this and many other problems soon. We discussed nulls previously, but as a reminder, nulls are empty fields. This kind of dirty data requires a little more work than just fixing a spelling error or changing a format. In this example, the data analysts would need to research which customer had a consultation on July 4th, 2020. Then when they find the correct information, they'd have to add it to the spreadsheet.\nAnother common type of dirty data is duplicated.\nMaybe two different people added this appointment on August 13th, not realizing that someone else had already done it or maybe the person entering the data hit copy and paste by accident. Whatever the reason, it's the data analyst job to identify this error and correct it by deleting one of the duplicates.\nNow, let's continue on to some other types of dirty data. The first has to do with labeling. To understand labeling, imagine trying to get a computer to correctly identify panda bears among images of all different kinds of animals. You need to show the computer thousands of images of panda bears. They're all labeled as panda bears. Any incorrectly labeled picture, like the one here that's just bear, will cause a problem. The next type of dirty data is having an inconsistent field length. You learned earlier that a field is a single piece of information from a row or column of a spreadsheet. Field length is a tool for determining how many characters can be keyed into a field. Assigning a certain length to the fields in your spreadsheet is a great way to avoid errors. For instance, if you have a column for someone's birth year, you know the field length is four because all years are four digits long. Some spreadsheet applications have a simple way to specify field lengths and make sure users can only enter a certain number of characters into a field. This is part of data validation. Data validation is a tool for checking the accuracy and quality of data before adding or importing it. Data validation is a form of data cleansing, which you'll learn more about soon. But first, you'll get familiar with more techniques for cleaning data. This is a very important part of the data analyst job. I look forward to sharing these data cleaning strategies with you.\n\nData-cleaning tools and techniques\nHi. Now that you're familiar with some of the most common types of dirty data, it's time to clean them up. As you've learned, clean data is essential to data integrity and reliable solutions and decisions. The good news is that spreadsheets have all kinds of tools you can use to get your data ready for analysis. The techniques for data cleaning will be different depending on the specific data set you're working with. So we won't cover everything you might run into, but this will give you a great starting point for fixing the types of dirty data analysts find most often. Think of everything that's coming up as a teaser trailer of data cleaning tools. I'm going to give you a basic overview of some common tools and techniques, and then we'll practice them again later on. Here, we'll discuss how to remove unwanted data, clean up text to remove extra spaces and blanks, fix typos, and make formatting consistent. However, before removing unwanted data, it's always a good practice to make a copy of the data set. That way, if you remove something that you end up needing in the future, you can easily access it and put it back in the data set. Once that's done, then you can move on to getting rid of the duplicates or data that isn't relevant to the problem you're trying to solve. Typically, duplicates appear when you're combining data sets from more than one source or using data from multiple departments within the same business. You've already learned a bit about duplicates, but let's practice removing them once more now using this spreadsheet, which lists members of a professional logistics association. Duplicates can be a big problem for data analysts. So it's really important that you can find and remove them before any analysis starts. Here's an example of what I'm talking about.\nLet's say this association has duplicates of one person's $500 membership in its database.\nWhen the data is summarized, the analyst would think there was $1,000 being paid by this member and would make decisions based on that incorrect data. But in reality, this member only paid $500. These problems can be fixed manually, but most spreadsheet applications also offer lots of tools to help you find and remove duplicates.\nNow, irrelevant data, which is data that doesn't fit the specific problem that you're trying to solve, also needs to be removed. Going back to our association membership list example, let's say a data analyst was working on a project that focused only on current members. They wouldn't want to include information on people who are no longer members,\nor who never joined in the first place.\nRemoving irrelevant data takes a little more time and effort because you have to figure out the difference between the data you need and the data you don't. But believe me, making those decisions will save you a ton of effort down the road.\nThe next step is removing extra spaces and blanks. Extra spaces can cause unexpected results when you sort, filter, or search through your data. And because these characters are easy to miss, they can lead to unexpected and confusing results. For example, if there's an extra space and in a member ID number, when you sort the column from lowest to highest, this row will be out of place.\nTo remove these unwanted spaces or blank cells, you can delete them yourself.\nOr again, you can rely on your spreadsheets, which offer lots of great functions for removing spaces or blanks automatically. The next data cleaning step involves fixing misspellings, inconsistent capitalization, incorrect punctuation, and other typos. These types of errors can lead to some big problems. Let's say you have a database of emails that you use to keep in touch with your customers. If some emails have misspellings, a period in the wrong place, or any other kind of typo, not only do you run the risk of sending an email to the wrong people, you also run the risk of spamming random people. Think about our association membership example again. Misspelling might cause the data analyst to miscount the number of professional members if they sorted this membership type\nand then counted the number of rows.\nLike the other problems you've come across, you can also fix these problems manually.\nOr you can use spreadsheet tools, such as spellcheck, autocorrect, and conditional formatting to make your life easier. There's also easy ways to convert text to lowercase, uppercase, or proper case, which is one of the things we'll check out again later. All right, we're getting there. The next step is removing formatting. This is particularly important when you get data from lots of different sources. Every database has its own formatting, which can cause the data to seem inconsistent. Creating a clean and consistent visual appearance for your spreadsheets will help make it a valuable tool for you and your team when making key decisions. Most spreadsheet applications also have a \"clear formats\" tool, which is a great time saver. Cleaning data is an essential step in increasing the quality of your data. Now you know lots of different ways to do that. In the next video, you'll take that knowledge even further and learn how to clean up data that's come from more than one source.\n\nCleaning data from multiple sources\nWelcome back. So far you've learned a lot about dirty data and how to clean up the most common errors in a dataset. Now we're going to take that a step further and talk about cleaning up multiple datasets. Cleaning data that comes from two or more sources is very common for data analysts, but it does come with some interesting challenges. A good example is a merger, which is an agreement that unites two organizations into a single new one. In the logistics field, there's been lots of big changes recently, mostly because of the e-commerce boom. With so many people shopping online, it makes sense that the companies responsible for delivering those products to their homes are in the middle of a big shake-up. When big things happen in an industry, it's common for two organizations to team up and become stronger through a merger. Let's talk about how that will affect our logistics association. As a quick reminder, this spreadsheet lists association member ID numbers, first and last names, addresses, how much each member pays in dues, when the membership expires, and the membership types. Now, let's think about what would happen if the International Logistics Association decided to get together with the Global Logistics Association in order to help their members handle the incredible demands of e-commerce. First, all the data from each organization would need to be combined using data merging. Data merging is the process of combining two or more datasets into a single dataset. This presents a unique challenge because when two totally different datasets are combined, the information is almost guaranteed to be inconsistent and misaligned. For example, the Global Logistics Association's spreadsheet has a separate column for a person's suite, apartment, or unit number, but the International Logistics Association combines that information with their street address. This needs to be corrected to make the number of address columns consistent. Next, check out how the Global Logistics Association uses people's email addresses as their member ID, while the International Logistics Association uses numbers. This is a big problem because people in a certain industry, such as logistics, typically join multiple professional associations. There's a very good chance that these datasets include membership information on the exact same person, just in different ways. It's super important to remove those duplicates. Also, the Global Logistics Association has many more member types than the other organization.\nOn top of that, it uses a term, \"Young Professional\" instead of \"Student Associate.\"\nBut both describe members who are still in school or just starting their careers. If you were merging these two datasets, you'd need to work with your team to fix the fact that the two associations describe memberships very differently. Now you understand why the merging of organizations also requires the merging of data, and that can be tricky. But there's lots of other reasons why data analysts merge datasets. For example, in one of my past jobs, I merged a lot of data from multiple sources to get insights about our customers' purchases. The kinds of insights I gained helped me identify customer buying patterns. When merging datasets, I always begin by asking myself some key questions to help me avoid redundancy and to confirm that the datasets are compatible. In data analytics, compatibility describes how well two or more datasets are able to work together. The first question I would ask is, do I have all the data I need? To gather customer purchase insights, I wanted to make sure I had data on customers, their purchases, and where they shopped. Next I would ask, does the data I need exist within these datasets? As you learned earlier in this program, this involves considering the entire dataset analytically. Looking through the data before I start using it lets me get a feel for what it's all about, what the schema looks like, if it's relevant to my customer purchase insights, and if it's clean data. That brings me to the next question. Do the datasets need to be cleaned, or are they ready for me to use? Because I'm working with more than one source, I will also ask myself, are the datasets cleaned to the same standard? For example, what fields are regularly repeated? How are missing values handled? How recently was the data updated? Finding the answers to these questions and understanding if I need to fix any problems at the start of a project is a very important step in data merging. In both of the examples we explored here, data analysts could use either the spreadsheet tools or SQL queries to clean up, merge, and prepare the datasets for analysis. Depending on the tool you decide to use, the cleanup process can be simple or very complex. Soon, you'll learn how to make the best choice for your situation. As a final note, programming languages like R are also very useful for cleaning data. You'll learn more about how to use R and other concepts we covered soon.\n\nData-cleaning features in spreadsheets\nHi again. As you learned earlier, there's a lot of different ways to clean up data. I've shown you some examples of how you can clean data manually, such as searching for and fixing misspellings or removing empty spaces and duplicates. We also learned that lots of spreadsheet applications have tools that help simplify and speed up the data cleaning process. There's a lot of great efficiency tools that data analysts use all the time, such as conditional formatting, removing duplicates, formatting dates, fixing text strings and substrings, and splitting text to columns. We'll explore those in more detail now. The first is something called conditional formatting. Conditional formatting is a spreadsheet tool that changes how cells appear when values meet specific conditions. Likewise, it can let you know when a cell does not meet the conditions you've set. Visual cues like this are very useful for data analysts, especially when we're working in a large spreadsheet with lots of data. Making certain data points standout makes the information easier to understand and analyze. For cleaning data, knowing when the data doesn't follow the condition is very helpful. Let's return to the logistics association spreadsheet to check out conditional formatting in action. We'll use conditional formatting to highlight blank cells. That way, we know where there's missing information so we can add it to the spreadsheet. To do this, we'll start by selecting the range we want to search. For this example we're not focused on address 3 and address 5. The fields will include all the columns in our spreadsheets, except for F and H. Next, we'll go to Format and choose Conditional formatting.\nGreat. Our range is automatically indicated in the field. The format rule will be to format cells if the cell is empty.\nFinally, we'll choose the formatting style. I'm going to pick a shade of bright pink, so my blanks really stand out.\nThen click \"Done,\" and the blank cells are instantly highlighted. The next spreadsheet tool removes duplicates. As you've learned before, it's always smart to make a copy of the data set before removing anything. Let's do that now.\nGreat, now we can continue. You might remember that our example spreadsheet has one association member listed twice.\nTo fix that, go to Data and select \"Remove duplicates.\" \"Remove duplicates\" is a tool that automatically searches for and eliminates duplicate entries from a spreadsheet. Choose \"Data has header row\" because our spreadsheet has a row at the very top that describes the contents of each column. Next, select \"All\" because we want to inspect our entire spreadsheet. Finally, \"Remove duplicates.\"\nYou'll notice the duplicate row was found and immediately removed.\nAnother useful spreadsheet tool enables you to make formats consistent. For example, some of the dates in this spreadsheet are in a standard date format.\nThis could be confusing if you wanted to analyze when association members joined, how often they renewed their memberships, or how long they've been with the association. To make all of our dates consistent, first select column J, then go to \"Format,\" select \"Number,\" then \"Date.\" Now all of our dates have a consistent format. Before we go over the next tool, I want to explain what a text string is. In data analytics, a text string is a group of characters within a cell, most often composed of letters. An important characteristic of a text string is its length, which is the number of characters in it. You'll learn more about that soon. For now, it's also useful to know that a substring is a smaller subset of a text string. Now let's talk about Split. Split is a tool that divides a text string around the specified character and puts each fragment into a new and separate cell. Split is helpful when you have more than one piece of data in a cell and you want to separate them out. This might be a person's first and last name listed together, or it could be a cell that contains someone's city, state, country, and zip code, but you actually want each of those in its own column. Let's say this association wanted to analyze all of the different professional certifications its members have earned. To do this, you want each certification separated out into its own column. Right now, the certifications are separated by a comma. That's the specified text separating each item, also called the delimiter. Let's get them separated. Highlight the column, then select \"Data,\" and \"Split text to columns.\"\nThis spreadsheet application automatically knew that the comma was a delimiter and separated each certification. But sometimes you might need to specify what the delimiter should be. You can do that here.\nSplit text to columns is also helpful for fixing instances of numbers stored as text. Sometimes values in your spreadsheet will seem like numbers, but they're formatted as text. This can happen when copying and pasting from one place to another or if the formatting's wrong. For this example, let's check out our new spreadsheet from a cosmetics maker. If a data analyst wanted to determine total profits, they could add up everything in column F. But there's a problem; one of the cells has an error. If you check into it, you learn that the \"707\" in this cell is text and can't be changed into a number. When the spreadsheet tries to multiply the cost of the product by the number of units sold, it's unable to make the calculation. But if we select the orders column and choose \"Split text to columns,\"\nthe error is resolved because now it can be treated as a number. Coming up, you'll learn about a tool that does just the opposite. CONCATENATE is a function that joins multiple text strings into a single string. Spreadsheets are a very important part of data analytics. They save data analysts time and effort and help us eliminate errors each and every day. Here, you've learned about some of the most common tools that we use. But there's a lot more to come. Next, we'll learn even more about data cleaning with spreadsheet tools. Bye for now!\n\nOptimize the data-cleaning process\nWelcome back. You've learned about some very useful data- cleaning tools that are built right into spreadsheet applications. Now we'll explore how functions can optimize your efforts to ensure data integrity. As a reminder, a function is a set of instructions that performs a specific calculation using the data in a spreadsheet. The first function we'll discuss is called COUNTIF. COUNTIF is a function that returns the number of cells that match a specified value. Basically, it counts the number of times a value appears in a range of cells. Let's go back to our professional association spreadsheet. In this example, we want to make sure the association membership prices are listed accurately. We'll use COUNTIF to check for some common problems, like negative numbers or a value that's much less or much greater than expected. To start, let's find the least expensive membership: $100 for student associates. That'll be the lowest number that exists in this column. If any cell has a value that's less than 100, COUNTIF will alert us. We'll add a few more rows at the bottom of our spreadsheet,\nthen beneath column H, type \"member dueS less than $100.\" Next, type the function in the cell next to it. Every function has a certain syntax that needs to be followed for it to work. Syntax is a predetermined structure that includes all required information and its proper placement. The syntax of a COUNTIF function should be like this: Equals COUNTIF, open parenthesis, range, comma, the specified value in quotation marks and a closed parenthesis. It will show up like this.\nWhere I2 through I72 is the range, and the value is less than 100. This tells the function to go through column I, and return a count of all cells that contain a number less than 100. Turns out there is one! Scrolling through our data, we find that one piece of data was mistakenly keyed in as a negative number. Let's fix that now. Now we'll use COUNTIF to search for any values that are more than we would expect. The most expensive membership type is $500 for corporate members. Type the function in the cell.\nThis time it will appear like this: I2 through I72 is still the range, but the value is greater than 500.\nThere's one here too. Check it out.\nThis entry has an extra zero. It should be $100.\nThe next function we'll discuss is called LEN. LEN is a function that tells you the length of the text string by counting the number of characters it contains. This is useful when cleaning data if you have a certain piece of information in your spreadsheet that you know must contain a certain length. For example, this association uses six-digit member identification codes. If we'd just imported this data and wanted to be sure our codes are all the correct number of digits, we'd use LEN. The syntax of LEN is equals LEN, open parenthesis, the range, and the close parenthesis. We'll insert a new column after Member ID.\nThen type an equals sign and LEN. Add an open parenthesis. The range is the first Member ID number in A2. Finish the function by closing the parenthesis. It tells us that there are six characters in cell A2. Let's continue the function through the entire column and find out if any results are not six. But instead of manually going through our spreadsheet to search for these instances, we'll use conditional formatting. We talked about conditional formatting earlier. It's a spreadsheet tool that changes how cells appear when values meet specific conditions. Let's practice that now. Select all of column B except for the header. Then go to Format and choose Conditional formatting. The format rule is to format cells if not equal to six.\nClick \"Done.\" The cell with the seven inside is highlighted.\nNow we're going to talk about LEFT and RIGHT. LEFT is a function that gives you a set number of characters from the left side of a text string. RIGHT is a function that gives you a set number of characters from the right side of a text string. As a quick reminder, a text string is a group of characters within a cell, commonly composed of letters, numbers, or both. To see these functions in action, let's go back to the spreadsheet from the cosmetics maker from earlier. This spreadsheet contains product codes. Each has a five-digit numeric code and then a four-character text identifier.\nBut let's say we only want to work with one side or the other. You can use LEFT or RIGHT to give you the specific set of characters or numbers you need. We'll practice cleaning up our data using the LEFT function first. The syntax of LEFT is equals LEFT, open parenthesis, the range, a comma, and a number of characters from the left side of the text string we want. Then, we finish it with a closed parenthesis. Here, our project requires just the five-digit numeric codes. In a separate column,\ntype equals LEFT, open parenthesis, then the range. Our range is A2. Then, add a comma, and then number 5 for our five- digit product code. Finally, finish the function with a closed parenthesis. Our function should show up like this. Press \"Enter.\" And now, we have a substring, which is the number part of the product code only.\nClick and drag this function through the entire column to separate out the rest of the product codes by number only.\nNow, let's say our project only needs the four-character text identifier.\nFor that, we'll use the RIGHT function, and the next column will begin the function. The syntax is equals RIGHT, open parenthesis, the range, a comma and the number of characters we want. Then, we finish with a closed parenthesis. Let's key that in now. Equals right, open parenthesis, and the range is still A2. Add a comma. This time, we'll tell it that we want the first four characters from the right. Close up the parenthesis and press \"Enter.\" Then, drag the function throughout the entire column.\nNow, we can analyze the product in our spreadsheet based on either substring. The five-digit numeric code or the four character text identifier. Hopefully, that makes it clear how you can use LEFT and RIGHT to extract substrings from the left and right sides of a string. Now, let's learn how you can extract something in between. Here's where we'll use something called MID. MID is a function that gives you a segment from the middle of a text string. This cosmetics company lists all of its clients using a client code. It's composed of the first three letters of the city where the client is located, its state abbreviation, and then a three- digit identifier. But let's say a data analyst needs to work with just the states in the middle. The syntax for MID is equals MID, open parenthesis, the range, then a comma. When using MID, you always need to supply a reference point. In other words, you need to set where the function should start. After that, place another comma, and how many middle characters you want. In this case, our range is D2. Let's start the function in a new column.\nType equals MID, open parenthesis, D2. Then the first three characters represent a city name, so that means the starting point is the fourth. Add a comma and four. We also need to tell the function how many middle characters we want. Add one more comma, and two, because the state abbreviations are two characters long. Press \"Enter\" and bam, we just get the state abbreviation. Continue the MID function through the rest of the column.\nWe've learned about a few functions that help separate out specific text strings. But what if we want to combine them instead? For that, we'll use CONCATENATE, which is a function that joins together two or more text strings. The syntax is equals CONCATENATE, then an open parenthesis inside indicates each text string you want to join, separated by commas. Then finish the function with a closed parenthesis. Just for practice, let's say we needed to rejoin the left and right text strings back into complete product codes. In a new column, let's begin our function.\nType equals CONCATENATE, then an open parenthesis. The first text string we want to join is in H2. Then add a comma. The second part is in I2. Add a closed parenthesis and press \"Enter\". Drag it down through the entire column,\nand just like that, all of our product codes are back together.\nThe last function we'll learn about here is TRIM. TRIM is a function that removes leading, trailing, and repeated spaces in data. Sometimes when you import data, your cells have extra spaces, which can get in the way of your analysis.\nFor example, if this cosmetics maker wanted to look up a specific client name, it won't show up in the search if it has extra spaces. You can use TRIM to fix that problem. The syntax for TRIM is equals TRIM, open parenthesis, your range, and closed parenthesis. In a separate column,\ntype equals TRIM and an open parenthesis. The range is C2, as you want to check out the client names. Close the parenthesis and press \"Enter\". Finally, continue the function down the column.\nTRIM fixed the extra spaces.\nNow we know some very useful functions that can make your data cleaning even more successful. This was a lot of information. As always, feel free to go back and review the video and then practice on your own. We'll continue building on these tools soon, and you'll also have a chance to practice. Pretty soon, these data cleaning steps will become second nature, like brushing your teeth.\n\nDifferent data perspectives\nHi, let's get into it. Motivational speaker Wayne Dyer once said, \"If you change the way you look at things, the things you look at change.\" This is so true in data analytics. No two analytics projects are ever exactly the same. So it only makes sense that different projects require us to focus on different information differently.\nIn this video, we'll explore different methods that data analysts use to look at data differently and how that leads to more efficient and effective data cleaning.\nSome of these methods include sorting and filtering, pivot tables, a function called VLOOKUP, and plotting to find outliers.\nLet's start with sorting and filtering. As you learned earlier, sorting and filtering data helps data analysts customize and organize the information the way they need for a particular project. But these tools are also very useful for data cleaning.\nYou might remember that sorting involves arranging data into a meaningful order to make it easier to understand, analyze, and visualize.\nFor data cleaning, you can use sorting to put things in alphabetical or numerical order, so you can easily find a piece of data.\nSorting can also bring duplicate entries closer together for faster identification.\nFilters, on the other hand, are very useful in data cleaning when you want to find a particular piece of information.\nYou learned earlier that filtering means showing only the data that meets a specific criteria while hiding the rest.\nThis lets you view only the information you need.\nWhen cleaning data, you might use a filter to only find values above a certain number, or just even or odd values. Again, this helps you find what you need quickly and separates out the information you want from the rest.\nThat way you can be more efficient when cleaning your data.\nAnother way to change the way you view data is by using pivot tables.\nYou've learned that a pivot table is a data summarization tool that is used in data processing.\nPivot tables sort, reorganize, group, count, total or average data stored in the database. In data cleaning, pivot tables are used to give you a quick, clutter- free view of your data. You can choose to look at the specific parts of the data set that you need to get a visual in the form of a pivot table.\nLet's create one now using our cosmetic makers spreadsheet again.\nTo start, select the data we want to use. Here, we'll choose the entire spreadsheet. Select \"Data\" and then \"Pivot table.\"\nChoose \"New sheet\" and \"Create.\"\nLet's say we're working on a project that requires us to look at only the most profitable products. Items that earn the cosmetics maker at least $10,000 in orders. So the row we'll include is \"Total\" for total profits.\nWe'll sort in descending order to put the most profitable items at the top.\nAnd we'll show totals.\nNext, we'll add another row for products\nso that we know what those numbers are about. We can clearly determine tha the most profitable products have the product codes 15143 E-X-F-O and 32729 M-A-S-C.\nWe can ignore the rest for this particular project because they fall below $10,000 in orders.\nNow, we might be able to use context clues to assume we're talking about exfoliants and mascaras. But we don't know which ones, or if that assumption is even correct.\nSo we need to confirm what the product codes correspond to.\nAnd this brings us to the next tool. It's called VLOOKUP.\nVLOOKUP stands for vertical lookup. It's a function that searches for a certain value in a column to return a corresponding piece of information. When data analysts look up information for a project, it's rare for all of the data they need to be in the same place. Usually, you'll have to search across multiple sheets or even different databases.\nThe syntax of the VLOOKUP is equals VLOOKUP, open parenthesis, then the data you want to look up. Next is a comma and where you want to look for that data.\nIn our example, this will be the name of a spreadsheet followed by an exclamation point.\nThe exclamation point indicates that we're referencing a cell in a different sheet from the one we're currently working in.\nAgain, that's very common in data analytics.\nOkay, next is the range in the place where you're looking for data, indicated using the first and last cell separated by a colon. After one more comma is the column in the range containing the value to return.\nNext, another comma and the word \"false,\" which means that an exact match is what we're looking for.\nFinally, complete your function by closing the parentheses. To put it simply, VLOOKUP searches for the value in the first argument in the leftmost column of the specified location.\nThen the value of the third argument tells VLOOKUP to return the value in the same row from the specified column.\nThe \"false\" tells VLOOKUP that we want an exact match.\nSoon you'll learn the difference between exact and approximate matches. But for now, just know that V lookup takes the value in one cell and searches for a match in another place.\nLet's begin.\nWe'll type equals VLOOKUP.\nThen add the data we are looking for, which is the product data.\nThe dollar sign makes sure that the corresponding part of the reference remains unchanged.\nYou can lock just the column, just the row, or both at the same time.\nNext, we'll tell it to look at Sheet 2, in both columns\nWe added 2 to represent the second column.\nThe last term, \"false,\" says we wanted an exact match.\nWith this information, we can now analyze the data for only the most profitable products.\nGoing back to the two most profitable products, we can search for 15143 E-X-F-O And 32729 M-A-S-C. Go to Edit and then Find. Type in the product codes and search for them.\nNow we can learn which products we'll be using for this particular project.\nThe final tool we'll talk about is something called plotting. When you plot data, you put it in a graph chart, table, or other visual to help you quickly find what it looks like.\nPlotting is very useful when trying to identify any skewed data or outliers. For example, if we want to make sure the price of each product is correct, we could create a chart. This would give us a visual aid that helps us quickly figure out if anything looks like an error.\nSo let's select the column with our prices.\nThen we'll go to Insert and choose Chart.\nPick a column chart as the type. One of these prices looks extremely low.\nIf we look into it, we discover that this item has a decimal point in the wrong place.\nIt should be $7.30, not 73 cents.\nThat would have a big impact on our total profits. So it's a good thing we caught that during data cleaning.\nLooking at data in new and creative ways helps data analysts identify all kinds of dirty data.\nComing up, you'll continue practicing these new concepts so you can get more comfortable with them. You'll also learn additional strategies for ensuring your data is clean, and we'll provide you with effective insights. Great work so far.\n", "source": "coursera_b", "evaluation": "exam"}
{"instructions": ["Question 1. Which of the following SQL functions can be used to remove spaces from text strings? Select all that apply.\nA. LENGTH\nB. TRIM\nC. CAST\nD. COALESCE", "Question 2. Which of the following SQL functions can be used to create a unique key by combining two columns? Select all that apply.\nA. CONCAT\nB. LENGTH\nC. CAST\nD. COALESCE", "Question 3. When should you use the COALESCE function in SQL? Select all that apply.\nA. To return non-null values in a list\nB. To combine two columns into one\nC. To skip null values when making calculations\nD. To remove spaces from text strings", "Question 4. Which of the following SQL functions can be used to convert data from one datatype to another? Select all that apply.\nA. CAST\nB. CONCAT\nC. COVERT\nD. TRIM", "Question 5. In SQL, how can you sort the data in descending order? Select all that apply.\nA. Use the DESC keyword\nB. Use the LENGTH function\nC. Use the ORDER BY keyword\nD. Use the CAST function", "Question 6. Which of the following SQL functions can be used to add strings together to create new text strings? Select all that apply.\nA. ADD\nB. CONCAT\nC. CAST\nD. None of the above", "Question 7. What is the purpose of using the DISTINCT keyword in a SELECT statement in SQL? Select all that apply.\nA. To remove duplicate rows from the result set\nB. To combine two columns into one\nC. To sort data in ascending order\nD. To convert data from one datatype to another", "Question 8. Which SQL function can be used to return the first two letters of each country in a column named 'country'? Select all that apply.\nA. LENGTH\nB. TRIM\nC. CONCAT\nD. SUBSTR", "Question 9. Could you tell me which of the following statements are advantages of utilizing SQL? Choose all that apply.\nA. SQL can also be used to create apps.\nB. SQL provides robust mechanisms for data cleansing.\nC. SQL is flexible and can be used across different database applications.\nD. SQL is capable of managing extremely large datasets.", "Question 10. Identify the tasks from the following list that a data analyst could execute utilizing both SQL and spreadsheet software? Please select all relevant options.\nA. Execute arithmetic operations\nB. Efficiently handle large volumes of data\nC. Employ formulas\nD. Combine data", "Question 11. SQL, as a database interaction language, has several dialects. What should be the strategy of data analysts towards these SQL dialects? \nA. SQL dialects don\u2019t change often, so data analysts should pick one and master it.\nB. Different SQL dialects correspond to different database systems, thus data analysts should initially become proficient in Standard SQL.\nC. SQL dialects can differ from one organization to another, hence data analysts should acquire the dialect utilized by their respective company.\nD. There are various dialects of SQL, and it's obligatory for data analysts to learn each one of them.", "Question 12. What are the reasons that make data analysts opt for SQL? Please choose all relevant options.\nA. SQL is a coding language that also has the capability to develop web applications.\nB. SQL is a potent software tool.\nC. SQL holds recognition as a standard in the professional realm.\nD. SQL has the capacity to manage enormous volumes of data.", "Question 13. Under what circumstances would a data analyst opt for spreadsheets over SQL? Please choose all applicable options.\nA. When conducting a visual review of data\nB. When dealing with a dataset comprising over 1,000,000 rows\nC. When handling a relatively small dataset\nD. When utilizing a language to interface with several database applications"], "outputs": ["B", "A", "AC", "A", "AC", "B", "A", "D", "BCD", "ACD", "BC", "CD", "AC"], "input": "Using SQL to clean data\nWelcome back and great job on that last weekly challenge. Now that we know the difference between cleaning dirty data and some general data cleaning techniques, let's focus on data cleaning using SQL. Coming up we'll learn about the different data cleaning functions in spreadsheets and SQL and how SQL can be used to clean large data sets. I'll also show you how to develop some basic search queries for databases and how to apply basic SQL functions for transforming data and cleaning strings. Cleaning your data is the last step in the data analysis process before you can move on to the actual analysis, and SQL has a lot of great tools that can help you do that.\nBut before we start cleaning databases, we'll take a closer look at SQL and when to use it. I'll see you there.\n\nUnderstanding SQL capabilities\nHello, again. So before we go over all the ways data analysts use SQL to clean data, I want to formally introduce you to SQL. We've talked about SQL a lot already. You've seen some databases and some basic functions in SQL, and you've even seen how SQL can be used to process data. But now let's actually define SQL. SQL is a structured query language that analysts use to work with databases. Data analysts usually use SQL to deal with large datasets because it can handle huge amounts of data. And I mean trillions of rows. That's a lot of rows to wrap your head around. So let me give you an idea about how much data that really is.\nImagine a data set that contains the names of all 8 billion people in the world. It would take the average person 101 years to read all 8 billion names. SQL can process this in seconds. Personally, I think that's pretty cool. Other tools like spreadsheets might take a really long time to process that much data, which is one of the main reasons data analysts choose to use SQL, when dealing with big datasets. Let me give you a short history on SQL. Development on SQL actually began in the early 70s.\nIn 1970, Edgar F.Codd developed the theory about relational databases. You might remember learning about relational databases a while back. This is a database that contains a series of tables that can be connected to form relationships. At the time IBM was using a relational database management system called System R. Well, IBM computer scientists were trying to figure out a way to manipulate and retrieve data from IBM System R. Their first query language was hard to use. So they quickly moved on to the next version, SQL. In 1979, after extensive testing SQL, now just spelled S-Q-L, was released publicly. By 1986, SQL had become the standard language for relational database communication, and it still is. This is another reason why data analysts choose SQL. It's a well-known standard within the community. The first time I used SQL to pull data from a real database was for my first job as a data analyst. I didn't have any background knowledge about SQL before that. I only found out about it because it was a requirement for that job. The recruiter for that position gave me a week to learn it. So I went online and researched it and ended up teaching myself SQL. They actually gave me a written test as part of the job application process. I had to write SQL queries and functions on a whiteboard. But I've been using SQL ever since. And I really like it. And just like I learned SQL on my own, I wanted to remind you that you can figure things out yourself too. There's tons of great online resources for learning. So don't let one job requirement stand in your way without doing some research first. Now that we know a little more about why analysts choose to work with SQL when they're handling a lot of data and a little bit about the history of SQL, we'll move on and learn some practical applications for it. Coming up next, we'll check out some of the tools we learned in spreadsheets and figure out if any of those apply to working in SQL. Spoiler alert, they do. See you soon.\n\nSpreadsheets versus SQL\nHey there. So far we've learned about both spreadsheets and SQL. While there's lots of differences between spreadsheets and SQL, you'll find some similarities too. Let's check out what spreadsheets and SQL have in common and how they're different. Spreadsheets and SQL actually have a lot in common. Specifically, there's tools you can use in both spreadsheets and SQL to achieve similar results. We've already learned about some tools for cleaning data in spreadsheets, which means you already know some tools that you can use in SQL. For example, you can still perform arithmetic, use formulas and join data when you're using SQL, so we'll build on the skills we've learned in spreadsheets and use them to do even more complex work in SQL. Here's an example of what I mean by more complex work. If we were working with health data for a hospital, we'd need to be able to access and process a lot of data. We might need demographic data, like patients' names, birthdays, and addresses, information about their insurance or past visits, public health data or even user generated data to add to their patient records. All of this data is being stored in different places, maybe even in different formats, and each location might have millions of rows and hundreds of related tables. This is way too much data to input manually, even for just one hospital. That's where SQL comes in handy. Instead of having to look at each individual data source and record it in our spreadsheet, we can use SQL to pull all this information from different locations in our database. Now, let's say we want to find something specific in all this data, like how many patients with a certain diagnosis came in today. In a spreadsheet we can use the COUNTIF function to find that out, or we can combine the COUNT and WHERE queries in SQL to find out how many rows match our search criteria. This will give us similar results, but works with a much larger and more complex set of data. Next, let's talk about how spreadsheets and SQL are different. First, it's important to understand that spreadsheets and SQL are different things. Spreadsheets are generated with a program like Excel or Google Sheets. These programs are designed to execute certain built-in functions. SQL on the other hand is a language that can be used to interact with database programs, like Oracle MySQL or Microsoft SQL Server. The differences between the two are mostly in how they're used. If a data analyst was given data in the form of a spreadsheet they'll probably do their data cleaning and analysis within that spreadsheet, but if they're working with a large data set with more than a million rows or multiple files within a database, it's easier, faster and more repeatable to use SQL. SQL can access and use a lot more data because it can pull information from different sources in the database automatically, unlike spreadsheets which only have access to the data you input. This also means that data is stored in multiple places. A data analyst might use spreadsheets stored locally on their hard drive or their personal cloud when they're working alone, but if they're on a larger team with multiple analysts who need to access and use data stored across a database, SQL might be a more useful tool. Because of these differences, spreadsheets and SQL are used for different things. As you already know, spreadsheets are good for smaller data sets and when you're working independently. Plus, spreadsheets have built-in functionalities, like spell check that can be really handy. SQL is great for working with larger data sets, even trillions of rows of data. Because SQL has been the standard language for communicating with databases for so long, it can be adapted and used for multiple database programs. SQL also records changes in queries, which makes it easy to track changes across your team if you're working collaboratively. Next, we'll learn more queries and functions in SQL that will give you some new tools to work with. You might even learn how to use spreadsheet tools in brand new ways. See you next time.\n\nWidely used SQL queries\nHey, welcome back. So far we've learned that SQL has some of the same tools as spreadsheets, but on a much larger scale. In this video, we'll learn some of the most widely used SQL queries that you can start using for your own data cleaning and eventual analysis. Let's get started. We've talked about queries as requests you put into the database to ask it to do things for you. Queries are a big part of using SQL. It's Structured Query Language, after all. Queries can help you do a lot of things, but there are some common ones that data analysts use all the time. So let's start there. First, I'll show you how to use the SELECT query. I've called this one out before, but now I'll add some new things for us to try out. Right now, the table viewer is blank because we haven't pulled anything from the database yet. For this example, the store we're working with is hosting a giveaway for customers in certain cities. We have a database containing customer information that we can use to narrow down which customers are eligible for the giveaway. Let's do that now. We can use SELECT to specify exactly what data we want to interact with in a table. If we combine SELECT with FROM, we can pull data from any table in this database as long as they know what the columns and rows are named. We might want to pull the data about customer names and cities from one of the tables. To do that, we can input SELECT name, comma, city FROM customer underscore data dot customer underscore address. To get this information from the customer underscore address table, which lives in the customer underscore data, data set. SELECT and FROM help specify what data we want to extract from the database and use. We can also insert new data into a database or update existing data. For example, maybe we have a new customer that we want to insert into this table. We can use the INSERT INTO query to put that information in. Let's start with where we're trying to insert this data, the customer underscore address table.\nWe also want to specify which columns we're adding this data to by typing their names in the parentheses.\nThat way, SQL can tell the database exactly where we were inputting new information. Then we'll tell it what values we're putting in.\nRun the query, and just like that, it added it to our table for us. Now, let's say we just need to change the address of a customer. Well, we can tell the database to update it for us. To do that, we need to tell it we're trying to update the customer underscore address table.\nThen we need to let it know what value we're trying to change.\nBut we also need to tell it where we're making that change specifically so that it doesn't change every address in the table.\nThere. Now this one customer's address has been updated. If we want to create a new table for this database, we can use the CREATE TABLE IF NOT EXISTS statement. Keep in mind, just running a SQL query doesn't actually create a table for the data we extract. It just stores it in our local memory. To save it, we'll need to download it as a spreadsheet or save the result into a new table. As a data analyst, there are a few situations where you might need to do just that. It really depends on what kind of data you're pulling and how often. If you're only using a total number of customers, you probably don't need a CSV file or a new table in your database. If you're using the total number of customers per day to do something like track a weekend promotion in a store, you might download that data as a CSV file so you can visualize it in a spreadsheet. But if you're being asked to pull this trend on a regular basis, you can create a table that will automatically refresh with the query you've written. That way, you can directly download the results whenever you need them for a report. Another good thing to keep in mind, if you're creating lots of tables within a database, you'll want to use the DROP TABLE IF EXISTS statement to clean up after yourself. It's good housekeeping. You probably won't be deleting existing tables very often. After all, that's the company's data, and you don't want to delete important data from their database. But you can make sure you're cleaning up the tables you've personally made so that there aren't old or unused tables with redundant information cluttering the database. There. Now you've seen some of the most widely used SQL queries in action. There's definitely more query keywords for you to learn and unique combinations that'll help you work within databases. But this is a great place to start. Coming up, we'll learn even more about queries in SQL and how to use them to clean our data. See you next time.\n\nCleaning string variables using SQL\nIt's so great to have you back. Now that we know some basic SQL queries and spent some time working in a database, let's apply that knowledge to something else we've been talking about: preparing and cleaning data. You already know that cleaning and completing your data before you analyze it is an important step. So in this video, I'll show you some ways SQL can help you do just that, including how to remove duplicates, as well as four functions to help you clean string variables. Earlier, we covered how to remove duplicates in spreadsheets using the Remove duplicates tool. In SQL, we can do the same thing by including DISTINCT in our SELECT statement. For example, let's say the company we work for has a special promotion for customers in Ohio. We want to get the customer IDs of customers who live in Ohio. But some customer information has been entered multiple times. We can get these customer IDs by writing SELECT customer_id FROM customer_data.customer_address. This query will give us duplicates if they exist in the table. If customer ID 9080 shows up three times in our table, our results will have three of that customer ID. But we don't want that. We want a list of all unique customer IDs. To do that, we add DISTINCT to our SELECT statement by writing, SELECT DISTINCT customer_id FROM customer_data.customer_address.\nNow, the customer ID 9080 will show up only once in our results. You might remember we've talked before about text strings as a group of characters within a cell, commonly composed of letters, numbers, or both.\nThese text strings need to be cleaned sometimes. Maybe they've been entered differently in different places across your database, and now they don't match.\nIn those cases, you'll need to clean them before you can analyze them. So here are some functions you can use in SQL to handle string variables. You might recognize some of these functions from when we talked about spreadsheets. Now it's time to see them work in a new way. Pull up the data set we shared right before this video. And you can follow along step-by-step with me during the rest of this video.\nThe first function I want to show you is LENGTH, which we've encountered before. If we already know the length our string variables are supposed to be, we can use LENGTH to double-check that our string variables are consistent. For some databases, this query is written as LEN, but it does the same thing. Let's say we're working with the customer_address table from our earlier example. We can make sure that all country codes have the same length by using LENGTH on each of these strings. So to write our SQL query, let's first start with SELECT and FROM. We know our data comes from the customer_address table within the customer_data data set. So we add customer_data.customer_address after the FROM clause. Then under SELECT, we'll write LENGTH, and then the column we want to check, country. To remind ourselves what this is, we can label this column in our results as letters_in_country. So we add AS letters_in_country, after LENGTH(country). The result we get is a list of the number of letters in each country listed for each of our customers. It seems like almost all of them are 2s, which means the country field contains only two letters. But we notice one that has 3. That's not good. We want our data to be consistent.\nSo let's check out which countries were incorrectly listed in our table. We can do that by putting the LENGTH(country) function that we created into the WHERE clause. Because we're telling SQL to filter the data to show only customers whose country contains more than two letters. So now we'll write SELECT country FROM customer_data.customer_address WHERE LENGTH(country) greater than 2.\nWhen we run this query, we now get the two countries where the number of letters is greater than the 2 we expect to find.\nThe incorrectly listed countries show up as USA instead of US. If we created this table, then we could update our table so that this entry shows up as US instead of USA. But in this case, we didn't create this table, so we shouldn't update it. We still need to fix this problem so we can pull a list of all the customers in the US, including the two that have USA instead of US. The good news is that we can account for this error in our results by using the substring function in our SQL query. To write our SQL query, let's start by writing the basic structure, SELECT, FROM, WHERE. We know our data is coming from the customer_address table from the customer_data data set. So we type in customer_data.customer_address, after FROM. Next, we tell SQL what data we want it to give us. We want all the customers in the US by their IDs. So we type in customer_id after SELECT. Finally, we want SQL to filter out only American customers. So we use the substring function after the WHERE clause. We're going to use the substring function to pull the first two letters of each country so that all of them are consistent and only contain two letters. To use the substring function, we first need to tell SQL the column where we found this error, country. Then we specify which letter to start with. We want SQL to pull the first two letters, so we're starting with the first letter, so we type in 1. Then we need to tell SQL how many letters, including this first letter, to pull. Since we want the first two letters, we need SQL to pull two total letters, so we type in 2. This will give us the first two letters of each country. We want US only, so we'll set this function to equals US. When we run this query, we get a list of all customer IDs of customers whose country is the US, including the customers that had USA instead of US. Going through our results, it seems like we have a couple duplicates where the customer ID is shown multiple times. Remember how we get rid of duplicates? We add DISTINCT before customer_id.\nSo now when we run this query, we have our final list of customer IDs of the customers who live in the US. Finally, let's check out the TRIM function, which you've come across before. This is really useful if you find entries with extra spaces and need to eliminate those extra spaces for consistency.\nFor example, let's check out the state column in our customer_address table. Just like we did for the country column, we want to make sure the state column has the consistent number of letters. So let's use the LENGTH function again to learn if we have any state that has more than two letters, which is what we would expect to find in our data table.\nWe start writing our SQL query by typing the basic SQL structure of SELECT, FROM, WHERE. We're working with the customer_address table in the customer_data data set. So we type in customer_data.customer_address after FROM. Next, we tell SQL what we want it to pull. We want it to give us any state that has more than two letters, so we type in state, after SELECT. Finally, we want SQL to filter for states that have more than two letters. This condition is written in the WHERE clause. So we type in LENGTH(state), and that it must be greater than 2 because we want the states that have more than two letters.\nWe want to figure out what the incorrectly listed states look like, if we have any. When we run this query, we get one result. We have one state that has more than two letters. But hold on, how can this state that seems like it has two letters, O and H for Ohio, have more than two letters? We know that there are more than two characters because we used the LENGTH(state) > 2 statement in the WHERE clause when filtering out results. So that means the extra characters that SQL is counting must then be a space. There must be a space after the H. This is where we would use the TRIM function. The TRIM function removes any spaces. So let's write a SQL query that accounts for this error. Let's say we want a list of all customer IDs of the customers who live in \"OH\" for Ohio. We start with the basic SQL structure: SELECT, FROM, WHERE. We know the data comes from the customer_address table in the customer_data data set, so we type in customer_data.customer_address after FROM. Next, we tell SQL what data we want. We want SQL to give us the customer IDs of customers who live in Ohio, so we type in customer_id after SELECT. Since we know we have some duplicate customer entries, we'll go ahead and type in DISTINCT before customer_id to remove any duplicate customer IDs from appearing in our results. Finally, we want SQL to give us the customer IDs of the customers who live in Ohio. We're asking SQL to filter the data, so this belongs in the WHERE clause. Here's where we'll use the TRIM function. To use the TRIM function, we tell SQL the column we want to remove spaces from, which is state in our case. And we want only Ohio customers, so we type in = 'OH'. That's it. We have all customer IDs of the customers who live in Ohio, including that customer with the extra space after the H.\nMaking sure that your string variables are complete and consistent will save you a lot of time later by avoiding errors or miscalculations. That's why we clean data in the first place. Hopefully functions like length, substring, and trim will give you the tools you need to start working with string variables in your own data sets. Next up, we'll check out some other ways you can work with strings and more advanced cleaning functions. Then you'll be ready to start working in SQL on your own. See you soon.\n\nAdvanced data cleaning functions, part 1\nHi there and welcome back. So far we've gone over some basic SQL queries and functions that can help you clean your data. We've also checked out some ways you can deal with string variables in SQL to make your job easier. Get ready to learn more functions for dealing with strings in SQL. Trust me, these functions will be really helpful in your work as a data analyst. In this video, we'll check out strings again and learn how to use the CAST function to correctly format data. When you import data that doesn't already exist in your SQL tables, the datatypes from the new dataset might not have been imported correctly. This is where the CAST function comes in handy. Basically, CAST can be used to convert anything from one data type to another. Let's check out an example. Imagine we're working with Lauren's furniture store. The owner has been collecting transaction data for the past year, but she just discovered that they can't actually organize their data because it hadn't been formatted correctly. We'll help her by converting our data to make it useful again. For example, let's say we want to sort all purchases by purchase_price in descending order. That means we want the most expensive purchase to show up first in our results. To write the SQL query, we start with the basic SQL structure. SELECT, FROM, WHERE. We know that data is stored in the customer_purchase table in the customer_data dataset. We write customer_data.customer_purchase after FROM. Next, we tell SQL what data to give us in the SELECT clause. We want to see the purchase_price data, so we type purchase_price after SELECT. Next is the WHERE clause. We are not filtering out any data since we want all purchase prices shown so we can take out the WHERE clause. Finally, to sort the purchase_price in descending order, we type ORDER BY purchase_price, DESC at the end of our query. Let's run this query. We see that 89.85 shows up at the top with 799.99 below it. But we know that 799.99 is a bigger number than 89.85. The database doesn't recognize that these are numbers, so it didn't sort them that way. If we go back to the customer_purchase table and take a look at its schema, we can see what datatype that database thinks purchase underscore price is. It says here, the database thinks purchase underscore price is a string, when in fact it is a float, which is a number that contains a decimal. That is why 89.85 shows up before 799.99. When we start letters, we start from the first letter before moving on to the second letter. If we want to sort the words apple and orange in descending order, we start with the first letters a and o. Since o comes after a, orange will show up first, then apple. The database did the same with 89.85 and 799.99. It started with the first letter, which in this case was a 8 and 7 respectively. Since 8 is bigger than 7, the database sorted 89.85 first and then 799.99. Because the database treated these as text strings, the database doesn't recognize these strings as floats because they haven't been typecast to match that datatype yet. Typecasting means converting data from one type to another, which is what we'll do with the CAST function. We use the CAST function to replace purchase_price with the new purchase_price that the database recognizes as float instead of string. We start by replacing purchase_price with CAST. Then we tell SQL the field we want to change, which is the purchase_price field. Next is a datatype we want to change purchase_price to, which is the float datatype. BigQuery stores numbers in a 64 bit system. The float data type is referenced as float64 in our query. This might be slightly different and other SQL platforms, but basically the 64 and float64 just indicates that we're casting numbers in the 64 bit system as floats. We also need to sort this new field, so we change purchase_price after ORDER BY to CAST purchase underscore price as float64. This is how we use the CAST function to allow SQL to recognize the purchase_price column as floats instead of text strings. Now we can start our purchases by purchase_price. Just like that, Lauren's furniture store has data that can actually be used for analysis. As a data analyst, you'll be asked to locate and organize data a lot, which is why you want to make sure you convert between data types early on. Businesses like our furniture store are interested in timely sales data, and you need to be able to account for that in your analysis. The CAST function can be used to change strings into other data types too, like date and time. As a data analyst, you might find yourself using data from various sources. Part of your job is making sure the data from those sources is recognizable and usable in your database so that you won't run into any issues with your analysis. Now you know how to do that. The CAST function is one great tool you can use when you're cleaning data. Coming up, we'll cover some other advanced functions that you can add to your toolbox. See you soon.\n\nAdvanced data-cleaning functions, part 2\n0:00\nHey there. Great to see you again. So far, we've seen some SQL functions in action. In this video, we'll go over more uses for CAST, and then learn about CONCAT and COALESCE. Let's get started. Earlier we talked about the CAST function, which let us typecast text strings into floats. I called out that the CAST function can be used to change into other data types too. Let's check out another example of how you can use CAST in your own data work. We've got the transaction data we were working with from our Lauren's Furniture Store example. But now, we'll check out the purchase date field. The furniture store owner has asked us to look at purchases that occurred during their sales promotion period in December. Let's write a SQL query that will pull date and purchase_price for all purchases that occurred between December 1st, 2020, and December 31st, 2020. We start by writing the basic SQL structure: SELECT, FROM, and WHERE. We know the data comes from the customer_purchase table in the customer_data dataset, so we write customer_data.customer_purchase after FROM. Next, we tell SQL what data to pull. Since we want date and purchase_price, we add them into the SELECT statement.\nFinally, we want SQL to filter for purchases that occurred in December only. We type date BETWEEN '2020-12-01' AND '2020-12-31' in the WHERE clause. Let's run the query. Four purchases occurred in December, but the date field looks odd. That's because the database recognizes this date field as datetime, which consists of the date and time. Our SQL query still works correctly, even if the date field is datetime instead of date. But we can tell SQL to convert the date field into the date data type so we see just the day and not the time. To do that, we use the CAST() function again. We'll use the CAST() function to replace the date field in our SELECT statement with the new date field that will show the date and not the time. We can do that by typing CAST() and adding the date as the field we want to change. Then we tell SQL the data type we want instead, which is the date data type.\nThere. Now we can have cleaner results for purchases that occurred during the December sales period. CAST is a super useful function for cleaning and sorting data, which is why I wanted you to see it in action one more time. Next up, let's check out the CONCAT function. CONCAT lets you add strings together to create new text strings that can be used as unique keys. Going back to our customer_purchase table, we see that the furniture store sells different colors of the same product. The owner wants to know if customers prefer certain colors, so the owner can manage store inventory accordingly. The problem is, the product_code is the same, regardless of the product color. We need to find another way to separate products by color, so we can tell if customers prefer one color over the others. We'll use CONCAT to produce a unique key that'll help us tell the products apart by color and count them more easily. Let's write our SQL query by starting with the basic structure: SELECT, FROM, and WHERE. We know our data comes from the customer_purchase table and the customer_data dataset. We type \"customer_data.customer_purchase\" after FROM Next, we tell SQL what data to pull. We use the CONCAT() function here to get that unique key of product and color. So we type CONCAT(), the first column we want, product_code, and the other column we want, product_color.\nFinally, let's say we want to look at couches, so we filter for couches by typing product = 'couch' in the WHERE clause. Now we can count how many times each couch was purchased and figure out if customers preferred one color over the others.\nWith CONCAT, the furniture store can find out which color couches are the most popular and order more. I've got one last advanced function to show you, COALESCE. COALESCE can be used to return non-null values in a list. Null values are missing values. If you have a field that's optional in your table, it'll have null in that field for rows that don't have appropriate values to put there. Let's open the customer_purchase table so I can show you what I mean. In the customer_purchase table, we can see a couple rows where product information is missing. That is why we see nulls there. But for the rows where product name is null, we see that there is product_code data that we can use instead. We'd prefer SQL to show us the product name, like bed or couch, because it's easier for us to read. But if the product name doesn't exist, we can tell SQL to give us the product_code instead. That is where the COALESCE function comes into play. Let's say we wanted a list of all products that were sold. We want to use the product_name column to understand what kind of product was sold. We write our SQL query with the basic SQL structure: Select, From, AND Where. We know our data comes from customer_purchase table and the customer_data dataset. We type \"customer_data.customer_purchase\" after FROM. Next, we tell SQL the data we want. We want a list of product names, but if names aren't available, then give us the product code. Here is where we type \"COALESCE.\" then we tell SQL which column to check first, product, and which column to check second if the first column is null, product_code. We'll name this new field as product_info. Finally, we are not filtering out any data, so we can take out the WHERE clause. This gives us product information for each purchase. Now we have a list of all products that were sold for the owner to review. COALESCE can save you time when you're making calculations too by skipping any null values and keeping your math correct. Those were just some of the advanced functions you can use to clean your data and get it ready for the next step in the analysis process. You'll discover more as you continue working in SQL. But that's the end of this video and this module. Great work. We've covered a lot of ground. You learned the different data- cleaning functions in spreadsheets and SQL and the benefits of using SQL to deal with large datasets. We also added some SQL formulas and functions to your toolkit, and most importantly, we got to experience some of the ways that SQL can help you get data ready for your analysis. After this, you'll get to spend some time learning how to verify and report your cleaning results so that your data is squeaky clean and your stakeholders know it. But before that, you've got another weekly challenge to tackle. You've got this. Some of these concepts might seem challenging at first, but they'll become second nature to you as you progress in your career. It just takes time and practice. Speaking of practice, feel free to go back to any of these videos and rewatch or even try some of these commands on your own. Good luck. I'll see you again when you're ready.\n", "source": "coursera_b", "evaluation": "exam"}
{"instructions": ["Question 1. Which of the following are important reasons to document data cleaning changes? Select all that apply.\nA. Recover data-cleaning errors\nB. Inform other users of changes\nC. Determine the quality of the data\nD. Improve stakeholder communication", "Question 2. Ensuring data accuracy is a crucial step in the data purification process. Which activities are associated with this accuracy assurance? Choose all relevant options.\nA. Reviewing the data-cleansing work\nB. Sharing update lists with involved parties\nC. Correcting any mistakes found by data experts\nD. Aligning the initial project objectives with the results.", "Question 3. In the context of data analytics, what is the purpose of asking action-oriented questions? Select all that apply.\nA. Encourage change\nB. Generate insights\nC. Help solve problems\nD. Identify patterns", "Question 4. A data analyst is cleaning a dataset with inconsistent formats and repeated cases. They use the TRIM function to remove extra spaces from string variables. What other tools can they use for data cleaning? Select all that apply.\nA. Import data\nB. Remove duplicates\nC. Pivot table\nD. Protect sheet", "Question 5. What can a pivot table be used for during the data cleaning process? Select all that apply.\nA. Identify repeated errors in the data\nB. Summarize data stored in a database\nC. Group and count data\nD. Protect sensitive data", "Question 6. In the context of data cleaning, what is the purpose of a changelog? Select all that apply.\nA. Track modifications made to a project\nB. Keep a chronological order of changes\nC. Recover lost data\nD. Inform stakeholders of changes", "Question 7. Documenting data-cleaning makes it possible to achieve what goals? Select the false option.\nA. Demonstrate to project stakeholders that you are accountable\nB. Be transparent about your process\nC. Visualize the results of your data analysis\nD. Keep team members on the same page", "Question 8. Which function does not removes leading, trailing, and repeated spaces in data? Select all that apply.\nA. CUT\nB. CROP\nC. TRIM\nD. TIDY", "Question 9. What are the benefits of using a version history in spreadsheets for data cleaning? Select all that apply.\nA. Track changes made by different users\nB. Revert to a previous version of the data\nC. Identify errors in the data\nD. Protect sensitive data", "Question 10. Which of the following data errors can not be eliminated by documenting the data-cleaning process? Select all that apply.\nA. Human error in data entry\nB. System issues\nC. Flawed processes\nD. Premature feedback"], "outputs": ["ABC", "ACD", "ABC", "BC", "ABC", "ABD", "C", "ABD", "ABC", "D"], "input": "Verifying and reporting results\nHi there, great to have you back. You've been learning a lot about the importance of clean data and explored some tools and strategies to help you throughout the cleaning process. In these videos, we'll be covering the next step in the process: verifying and reporting on the integrity of your clean data. Verification is a process to confirm that a data cleaning effort was well- executed and the resulting data is accurate and reliable. It involves rechecking your clean dataset, doing some manual clean ups if needed, and taking a moment to sit back and really think about the original purpose of the project. That way, you can be confident that the data you collected is credible and appropriate for your purposes. Making sure your data is properly verified is so important because it allows you to double-check that the work you did to clean up your data was thorough and accurate. For example, you might have referenced an incorrect cellphone number or accidentally keyed in a typo. Verification lets you catch mistakes before you begin analysis. Without it, any insights you gain from analysis can't be trusted for decision-making. You might even risk misrepresenting populations or damaging the outcome of a product that you're actually trying to improve. I remember working on a project where I thought the data I had was sparkling clean because I'd use all the right tools and processes, but when I went through the steps to verify the data's integrity, I discovered a semicolon that I had forgotten to remove. Sounds like a really tiny error, I know, but if I hadn't caught the semicolon during verification and removed it, it would have led to some big changes in my results. That, of course, could have led to different business decisions. There's an example of why verification is so crucial. But that's not all. The other big part of the verification process is reporting on your efforts. Open communication is a lifeline for any data analytics project. Reports are a super effective way to show your team that you're being 100 percent transparent about your data cleaning. Reporting is also a great opportunity to show stakeholders that you're accountable, build trust with your team, and make sure you're all on the same page of important project details. Coming up, you'll learn different strategies for reporting, like creating data- cleaning reports, documenting your cleaning process, and using something called the changelog. A changelog is a file containing a chronologically ordered list of modifications made to a project. It's usually organized by version and includes the date followed by a list of added, improved, and removed features. Changelogs are very useful for keeping track of how a dataset evolved over the course of a project. They're also another great way to communicate and report on data to others. Along the way, you'll also see some examples of how verification and reporting can help you avoid repeating mistakes and save you and your team time. Ready to get started? Let's go!\n\nCleaning and your data expectations\nIn this video, we'll discuss how to begin the process of verifying your data-cleaning efforts.\nVerification is a critical part of any analysis project. Without it you have no way of knowing that your insights can be relied on for data-driven decision-making. Think of verification as a stamp of approval.\nTo refresh your memory, verification is a process to confirm that a data-cleaning effort was well-executed and the resulting data is accurate and reliable. It also involves manually cleaning data to compare your expectations with what's actually present. The first step in the verification process is going back to your original unclean data set and comparing it to what you have now. Review the dirty data and try to identify any common problems. For example, maybe you had a lot of nulls. In that case, you check your clean data to ensure no nulls are present. To do that, you could search through the data manually or use tools like conditional formatting or filters.\nOr maybe there was a common misspelling like someone keying in the name of a product incorrectly over and over again. In that case, you'd run a FIND in your clean data to make sure no instances of the misspelled word occur.\nAnother key part of verification involves taking a big-picture view of your project. This is an opportunity to confirm you're actually focusing on the business problem that you need to solve and the overall project goals and to make sure that your data is actually capable of solving that problem and achieving those goals.\nIt's important to take the time to reset and focus on the big picture because projects can sometimes evolve or transform over time without us even realizing it. Maybe an e-commerce company decides to survey 1000 customers to get information that would be used to improve a product. But as responses begin coming in, the analysts notice a lot of comments about how unhappy customers are with the e-commerce website platform altogether. So the analysts start to focus on that. While the customer buying experience is of course important for any e-commerce business, it wasn't the original objective of the project. The analysts in this case need to take a moment to pause, refocus, and get back to solving the original problem.\nTaking a big picture view of your project involves doing three things. First, consider the business problem you're trying to solve with the data.\nIf you've lost sight of the problem, you have no way of knowing what data belongs in your analysis. Taking a problem-first approach to analytics is essential at all stages of any project. You need to be certain that your data will actually make it possible to solve your business problem. Second, you need to consider the goal of the project. It's not enough just to know that your company wants to analyze customer feedback about a product. What you really need to know is that the goal of getting this feedback is to make improvements to that product. On top of that, you also need to know whether the data you've collected and cleaned will actually help your company achieve that goal. And third, you need to consider whether your data is capable of solving the problem and meeting the project objectives. That means thinking about where the data came from and testing your data collection and cleaning processes.\nSometimes data analysts can be too familiar with their own data, which makes it easier to miss something or make assumptions.\nAsking a teammate to review your data from a fresh perspective and getting feedback from others is very valuable in this stage.\nThis is also the time to notice if anything sticks out to you as suspicious or potentially problematic in your data. Again, step back, take a big picture view, and ask yourself, do the numbers make sense?\nLet's go back to our e-commerce company example. Imagine an analyst is reviewing the cleaned up data from the customer satisfaction survey. The survey was originally sent to 1,000 customers, but what if the analyst discovers that there is more than a thousand responses in the data? This could mean that one customer figured out a way to take the survey more than once. Or it could also mean that something went wrong in the data cleaning process, and a field was duplicated. Either way, this is a signal that it's time to go back to the data-cleaning process and correct the problem.\nVerifying your data ensures that the insights you gain from analysis can be trusted. It's an essential part of data-cleaning that helps companies avoid big mistakes. This is another place where data analysts can save the day.\nComing up, we'll go through the next steps in the data-cleaning process. See you there.\n\nThe final step in data cleaning\nHey there. In this video, we'll continue building on the verification process. As a quick reminder, the goal is to ensure that our data-cleaning work was done properly and the results can be counted on. You want your data to be verified so you know it's 100 percent ready to go. It's like car companies running tons of tests to make sure a car is safe before it hits the road. You learned that the first step in verification is returning to your original, unclean dataset and comparing it to what you have now. This is an opportunity to search for common problems. After that, you clean up the problems manually. For example, by eliminating extra spaces or removing an unwanted quotation mark. But there's also some great tools for fixing common errors automatically, such as TRIM and remove duplicates. Earlier, you learned that TRIM is a function that removes leading, trailing, and repeated spaces and data. Remove duplicates is a tool that automatically searches for and eliminates duplicate entries from a spreadsheet. Now sometimes you had an error that shows up repeatedly, and it can't be resolved with a quick manual edit or a tool that fixes the problem automatically. In these cases, it's helpful to create a pivot table. A pivot table is a data summarization tool that is used in data processing. Pivot tables sort, reorganize, group, count, total or average data stored in a database. We'll practice that now using the spreadsheet from a party supply store. Let's say this company was interested in learning which of its four suppliers is most cost-effective. An analyst pulled this data on the products the business sells, how many were purchased, which supplier provides them, the cost of the products, and the ultimate revenue. The data has been cleaned. But during verification, we noticed that one of the suppliers' names was keyed in incorrectly.\nWe could just correct the word as \"plus,\" but this might not solve the problem because we don't know if this was a one-time occurrence or if the problem's repeated throughout the spreadsheet. There are two ways to answer that question. The first is using Find and replace. Find and replace is a tool that looks for a specified search term in a spreadsheet and allows you to replace it with something else. We'll choose Edit. Then Find and replace. We're trying to find P-L-O-S, the misspelling of \"plus\" in the supplier's name. In some cases you might not want to replace the data. You just want to find something. No problem. Just type the search term, leave the rest of the options as default and click \"Done.\" But right now we do want to replace it with P-L-U-S. We'll type that in here. Then click \"Replace all\" and \"Done.\"\nThere we go. Our misspelling has been corrected. That was of course the goal. But for now let's undo our Find and replace so we can practice another way to determine if errors are repeated throughout a dataset, like with the pivot table. We'll begin by selecting the data we want to use. Choose column C. Select \"Data.\" Then \"Pivot Table.\" Choose \"New Sheet\" and \"Create.\"\nWe know this company has four suppliers. If we count the suppliers and the number doesn't equal four, we know there's a problem. First, add a row for suppliers.\nNext, we'll add a value for our suppliers and summarize by COUNTA. COUNTA counts the total number of values within a specified range. Here we're counting the number of times a supplier's name appears in column C. Note that there's also function called COUNT, which only counts the numerical values within a specified range. If we use it here, the result would be zero. Not what we have in mind. But in other special applications, COUNT would give us information we want for our current example. As you continue learning more about formulas and functions, you'll discover more interesting options. If you want to keep learning, search online for spreadsheet formulas and functions. There's a lot of great information out there. Our pivot table has counted the number of misspellings, and it clearly shows that the error occurs just once. Otherwise our four suppliers are accurately accounted for in our data. Now we can correct the spelling, and we verify that the rest of the supplier data is clean. This is also useful practice when querying a database. If you're working in SQL, you can address misspellings using a CASE statement. The CASE statement goes through one or more conditions and returns a value as soon as a condition is met. Let's discuss how this works in real life using our customer_name table. Check out how our customer, Tony Magnolia, shows up as Tony and Tnoy. Tony's name was misspelled. Let's say we want a list of our customer IDs and the customer's first names so we can write personalized notes thanking each customer for their purchase. We don't want Tony's note to be addressed incorrectly to \"Tnoy.\" Here's where we can use: the CASE statement. We'll start our query with the basic SQL structure. SELECT, FROM, and WHERE. We know that data comes from the customer_name table in the customer_data dataset, so we can add customer underscore data dot customer underscore name after FROM. Next, we tell SQL what data to pull in the SELECT clause. We want customer_id and first_name. We can go ahead and add customer underscore ID after SELECT. But for our customer's first names, we know that Tony was misspelled, so we'll correct that using CASE. We'll add CASE and then WHEN and type first underscore name equal \"Tnoy.\" Next we'll use the THEN command and type \"Tony,\" followed by the ELSE command. Here we will type first underscore name, followed by End As and then we'll type cleaned underscore name. Finally, we're not filtering our data, so we can eliminate the WHERE clause. As I mentioned, a CASE statement can cover multiple cases. If we wanted to search for a few more misspelled names, our statement would look similar to the original, with some additional names like this.\nThere you go. Now that you've learned how you can use spreadsheets and SQL to fix errors automatically, we'll explore how to keep track of our changes next.\n\nCapturing cleaning changes\nHi again. Now that you've learned how to make your data squeaky clean, it's time to address all the dirt you've left behind. When you clean your data, all the incorrect or outdated information is gone, leaving you with the highest-quality content. But all those changes you made to the data are valuable too. In this video, we'll discuss why keeping track of changes is important to every data project and how to document all your cleaning changes to make sure everyone stays informed. This involves documentation which is the process of tracking changes, additions, deletions and errors involved in your data cleaning effort. You can think of it like a crime TV show. Crime evidence is found at the scene and passed on to the forensics team. They analyze every inch of the scene and document every step, so they can tell a story with the evidence. A lot of times, the forensic scientist is called to court to testify about that evidence, and they have a detailed report to refer to. The same thing applies to data cleaning. Data errors are the crime, data cleaning is gathering evidence, and documentation is detailing exactly what happened for peer review or court. Having a record of how a data set evolved does three very important things. First, it lets us recover data-cleaning errors. Instead of scratching our heads, trying to remember what we might have done three months ago, we have a cheat sheet to rely on if we come across the same errors again later. It's also a good idea to create a clean table rather than overriding your existing table. This way, you still have the original data in case you need to redo the cleaning. Second, documentation gives you a way to inform other users of changes you've made. If you ever go on vacation or get promoted, the analyst who takes over for you will have a reference sheet to check in with. Third, documentation helps you to determine the quality of the data to be used in analysis. The first two benefits assume the errors aren't fixable. But if they are, a record gives the data engineer more information to refer to. It's also a great warning for ourselves that the data set is full of errors and should be avoided in the future. If the errors were time-consuming to fix, it might be better to check out alternative data sets that we can use instead. Data analysts usually use a changelog to access this information. As a reminder, a changelog is a file containing a chronologically ordered list of modifications made to a project. You can use and view a changelog in spreadsheets and SQL to achieve similar results. Let's start with the spreadsheet. We can use Sheet's version history, which provides a real-time tracker of all the changes and who made them from individual cells to the entire worksheet. To find this feature, click the File tab, and then select Version history.\nIn the right panel, choose an earlier version.\nWe can find who edited the file and the changes they made in the column next to their name.\nTo return to the current version, go to the top left and click \"Back.\" If you want to check out changes in a specific cell, we can right-click and select Show Edit History.\nAlso, if you want others to be able to browse a sheet's version history, you'll need to assign permission.\nNow let's switch gears and talk about SQL. The way you create and view a changelog with SQL depends on the software program you're using. Some companies even have their own separate software that keeps track of changelogs and important SQL queries. This gets pretty advanced. Essentially, all you have to do is specify exactly what you did and why when you commit a query to the repository as a new and improved query. This allows the company to revert back to a previous version if something you've done crashes the system, which has happened to me before. Another option is to just add comments as you go while you're cleaning data in SQL. This will help you construct your changelog after the fact. For now, we'll check out query history, which tracks all the queries you've run.\nYou can click on any of them to revert back to a previous version of your query or to bring up an older version to find what you've changed. Here's what we've got. I'm in the Query history tab. Listed on the bottom right are all the queries that run by date and time. You can click on this icon to the right of each individual query to bring it up to the Query editor. Changelogs like these are a great way to keep yourself on track. It also lets your team get real-time updates when they want them. But there's another way to keep the communication flowing, and that's reporting. Stick around, and you'll learn some easy ways to share your documentation and maybe impress your stakeholders in the process. See you in the next video.\n\nWhy documentation is important\nGreat, you're back. Let's set the stage. The crime is dirty data. We've gathered the evidence. It's been cleaned, verified, and cleaned again. Now it's time to present our evidence. We'll retrace the steps and present our case to our peers. As we discussed earlier, data cleaning, verifying, and reporting is a lot like crime drama. Now it's our day in court. Just like a forensic scientist testifies on the stand about the evidence, data analysts are counted on to present their findings after a data cleaning effort. Earlier, we learned how to document and track every step of the data cleaning process, which means we have solid information to pull from. As a quick refresher, documentation is the process of tracking changes, additions, deletions, and errors involved in a data cleaning effort, changelogs are good example of this. Since it's staged chronologically, it provides a real-time account of every modification. Documenting will be a huge time saver for you as a future data analyst. It's basically a cheatsheet you can refer to if you're working with the similar data set or need to address similar errors. While your team can view changelogs directly, stakeholders can't and have to rely on your report to know what you did. Lets check out how we might document our data cleaning process using example we worked with earlier. In that example, we found that this association had two instances of the same membership for $500 in its database.\nWe decided to fix this manually by deleting the duplicate info.\nThere're plenty of ways we could go about documenting what we did. One common way is to just create a doc listing out the steps we took and the impact they had. For example, first on your list would be that you remove the duplicate instance,\nwhich decreased the number of rows from 33 to 32,\nand lowered the membership total by $500.\nIf we were working with SQL, we could include a comment in the statement describing the reason for a change without affecting the execution of the statement. That's something a bit more advanced, which we'll talk about later. Regardless of how we capture and share our changelogs, we're setting ourselves up for success by being 100 percent transparent about our data cleaning. This keeps everyone on the same page and shows project stakeholders that we are accountable for effective processes. In other words, this helps build our credibility as witnesses who can be trusted to present all the evidence accurately during testimony. For dirty data, it's an open and shut case.\n\nFeedback and cleaning\nWelcome back. By now it's safe to say that verifying, documenting and reporting are valuable steps in the data-cleaning process. You have proof to give stakeholders that your data is accurate and reliable. And the effort to attain it was well-executed and documented. The next step is getting feedback about the evidence and using it for good, which we'll cover in this video.\nClean data is important to the task at hand. But the data-cleaning process itself can reveal insights that are helpful to a business. The feedback we get when we report on our cleaning can transform data collection processes, and ultimately business development. For example, one of the biggest challenges of working with data is dealing with errors. Some of the most common errors involve human mistakes like mistyping or misspelling, flawed processes like poor design of a survey form, and system issues where older systems integrate data incorrectly. Whatever the reason, data-cleaning can shine a light on the nature and severity of error-generating processes.\nWith consistent documentation and reporting, we can uncover error patterns in data collection and entry procedures and use the feedback we get to make sure common errors aren't repeated. Maybe we need to reprogram the way the data is collected or change specific questions on the survey form.\nIn more extreme cases, the feedback we get can even send us back to the drawing board to rethink expectations and possibly update quality control procedures. For example, sometimes it's useful to schedule a meeting with a data engineer or data owner to make sure the data is brought in properly and doesn't require constant cleaning.\nOnce errors have been identified and addressed, stakeholders have data they can trust for decision-making. And by reducing errors and inefficiencies in data collection, the company just might discover big increases to its bottom line. Congratulations! You now have the foundation you need to successfully verify a report on your cleaning results. Stay tuned to keep building on your new skills.\n", "source": "coursera_d", "evaluation": "exam"}
{"instructions": ["Question 1. In a deep neural network, which of the following weight initialization techniques can help in reducing the vanishing/exploding gradients problem?\nA. Initializing all weights to zero\nB. Initializing weights to a large constant value\nC. Initializing weights using Xavier initialization\nD. Initializing weights randomly with a uniform distribution", "Question 2. What is the purpose of dropout regularization in neural networks?\nA. To increase the size of the network\nB. To reduce overfitting problems\nC. To speed up the training process\nD. To improve the accuracy on the training set", "Question 3. Which of the following is true about gradient checking?\nA. It is used to verify the correctness of the backpropagation implementation\nB. It is used to speed up the training process\nC. It is used to initialize the weights of a neural network\nD. It is used to update the weights during training", "Question 4. When using dropout in a neural network, what happens at test time?\nA. Dropout is applied, and the keep_prob factor is used in the calculations\nB. Dropout is applied, but the keep_prob factor is not used in the calculations\nC. Dropout is not applied, and the keep_prob factor is used in the calculations\nD. Dropout is not applied, and the keep_prob factor is not used in the calculations", "Question 5. In the context of neural networks, what is the advantage of using the ReLU activation function over the sigmoid or tanh activation functions?\nA. It helps in preventing the vanishing gradient problem\nB. It helps in preventing the exploding gradient problem\nC. It helps in speeding up the training process\nD. It helps in improving the accuracy on the training set", "Question 6. Why is it essential to use the same mean and variance values for normalizing both the training set and the test set?\nA. To speed up the training process\nB. To ensure that the data is on the same scale\nC. To prevent overfitting\nD. To improve the accuracy on the training set", "Question 7. In deep neural networks, what is the effect of increasing the keep_prob value in dropout regularization?\nA. Increasing the regularization effect\nB. Reducing the regularization effect\nC. Causing the neural network to end up with a higher training set error\nD. Causing the neural network to end up with a lower training set error", "Question 8. Which of the following statements best describes the difference between Dropout and L2 regularization techniques in a neural network?\nA. Dropout prevents overfitting by randomly setting a fraction of input units to 0 at each update during training time, while L2 regularization prevents overfitting by adding a penalty equivalent to the square of the magnitude of weights to the loss function.\nB. Dropout adds a penalty equivalent to the square of the magnitude of weights to the loss function, while L2 regularization prevents overfitting by randomly setting a fraction of input units to 0 at each update during training time.\nC. Both Dropout and L2 regularization randomly set a fraction of input units to 0 at each update during training time to prevent overfitting.\nD. Both Dropout and L2 regularization add a penalty equivalent to the square of the magnitude of weights to the loss function to prevent overfitting.", "Question 9. If you have 12,000,000 examples for classification task, how would you split the train/dev/test set?\nA. 60% train . 20% dev . 20% test\nB. 98% train . 1% dev . 1% test\nC. 33% train . 33% dev . 33% test\nD. 99.98% train . 0.01% dev . 0.01% test", "Question 10. The validation and test set should:\nA. Come from the same distribution\nB. Have the same number of examples\nC. Be identical to each other (same (x,y) pairs)\nD. Come from different distributions", "Question 11. What are potential solutions you could consider if your Neural Network model appears to be suffering from high variance?\nA. Increase the number of units in each hidden layer\nB. Get more training data\nC. Get more test data\nD. Add regularization", "Question 12. You are working on an automated check-out kiosk for a supermarket, and are building a classifier for apples, bananas, and oranges. Suppose your classifier obtains a training set error of 0.1%, and a dev set error of 9%. Which of the following are promising things to try to improve your classifier? (Check all that apply.)\nA. Increase the regularization parameter lambda\nB. Decrease the regularization parameter lambda\nC. Get more training data\nD. Use a bigger neural network", "Question 13: What are the likely outcomes of raising the keep_prob parameter from 0.5 to 0.6? (Select the two most accurate responses)\nA. Augmenting the regularization effect\nB. Diminishing the regularization effect\nC. Resulting in a higher training set error for the neural network\nD. Resulting in a lower training set error for the neural network"], "outputs": ["C", "B", "A", "D", "A", "B", "BD", "A", "B", "A", "BD", "AC", "BD"], "input": "Regularization\nIf you suspect your neural network is over fitting your data, that is, you have a high variance problem, one of the first things you should try is probably regularization. The other way to address high variance is to get more training data that's also quite reliable. But you can't always get more training data, or it could be expensive to get more data. But adding regularization will often help to prevent overfitting, or to reduce variance in your network. So let's see how regularization works. Let's develop these ideas using logistic regression. Recall that for logistic regression, you try to minimize the cost function J, which is defined as this cost function. Some of your training examples of the losses of the individual predictions in the different examples, where you recall that w and b in the logistic regression, are the parameters. So w is an x-dimensional parameter vector, and b is a real number. And so, to add regularization to logistic regression, what you do is add to it, this thing, lambda, which is called the regularization parameter. I'll say more about that in a second. But lambda over 2m times the norm of w squared. So here, the norm of w squared, is just equal to sum from j equals 1 to nx of wj squared, or this can also be written w, transpose w, it's just a square Euclidean norm of the prime to vector w. And this is called L2 regularization.\nBecause here, you're using the Euclidean norm, also it's called the L2 norm with the parameter vector w. Now, why do you regularize just the parameter w? Why don't we add something here, you know, about b as well? In practice, you could do this, but I usually just omit this. Because if you look at your parameters, w is usually a pretty high dimensional parameter vector, especially with a high variance problem. Maybe w just has a lot of parameters, so you aren't fitting all the parameters well, whereas b is just a single number. So almost all the parameters are in w rather than b. And if you add this last term, in practice, it won't make much of a difference, because b is just one parameter over a very large number of parameters. In practice, I usually just don't bother to include it. But you can if you want. So L2 regularization is the most common type of regularization. You might have also heard of some people talk about L1 regularization. And that's when you add, instead of this L2 norm, you instead add a term that is lambda over m of sum over, of this. And this is also called the L1 norm of the parameter vector w, so the little subscript 1 down there, right? And I guess whether you put m or 2m in the denominator, is just a scaling constant. If you use L1 regularization, then w will end up being sparse. And what that means is that the w vector will have a lot of zeros in it. And some people say that this can help with compressing the model, because the set of parameters are zero, then you need less memory to store the model. Although, I find that, in practice, L1 regularization, to make your model sparse, helps only a little bit. So I don't think it's used that much, at least not for the purpose of compressing your model. And when people train your networks, L2 regularization is just used much, much more often. (Sorry, just fixing up some of the notation here). So, one last detail. Lambda here is called the regularization parameter.\nAnd usually, you set this using your development set, or using hold-out cross validation. When you try a variety of values and see what does the best, in terms of trading off between doing well in your training set versus also setting that two normal of your parameters to be small, which helps prevent over fitting. So lambda is another hyper parameter that you might have to tune. And by the way, for the programming exercises, lambda is a reserved keyword in the Python programming language. So in the programming exercise, we will have l-a-m-b-d,\nwithout the a, so as not to clash with the reserved keyword in Python. So we use l-a-m-b-d to represent the lambda regularization parameter.\nSo this is how you implement L2 regularization for logistic regression. How about a neural network? In a neural network, you have a cost function that's a function of all of your parameters, w[1], b[1] through w[capital L], b[capital L], where capital L is the number of layers in your neural network. And so the cost function is this, sum of the losses, sum over your m training examples. And so to add regularization, you add lambda over 2m, of sum over all of your parameters w, your parameter matrix is w, of their, that's called the squared norm. Where, this norm of a matrix, really the squared norm, is defined as the sum of i, sum of j, of each of the elements of that matrix, squared. And if you want the indices of this summation, this is sum from i=1 through n[l minus 1]. Sum from j=1 through n[l], because w is a n[l] by n[l minus 1] dimensional matrix, where these are the number of hidden units or number of units in layers [l minus 1] in layer l. So this matrix norm, it turns out is called the Frobenius norm of the matrix, denoted with a F in the subscript. So for arcane linear algebra technical reasons, this is not called the, you know, l2 norm of a matrix. Instead, it's called the Frobenius norm of a matrix. I know it sounds like it would be more natural to just call the l2 norm of the matrix, but for really arcane reasons that you don't need to know, by convention, this is called the Frobenius norm. It just means the sum of square of elements of a matrix. So how do you implement gradient descent with this? Previously, we would complete dw, you know, using backprop, where backprop would give us the partial derivative of J with respect to w, or really w for any given [l]. And then you update w[l], as w[l] minus the learning rate, times d. So this is before we added this extra regularization term to the objective. Now that we've added this regularization term to the objective, what you do is you take dw and you add to it, lambda over m times w. And then you just compute this update, same as before. And it turns out that with this new definition of dw[l], this is still, you know, this new dw[l] is still a correct definition of the derivative of your cost function, with respect to your parameters, now that you've added the extra regularization term at the end.\nAnd it's for this reason that L2 regularization is sometimes also called weight decay. So if I take this definition of dw[l] and just plug it in here, then you see that the update is w[l] gets updated as w[l] times the learning rate alpha times, you know, the thing from backprop,\nplus lambda over m, times w[l]. Let's move the minus sign there. And so this is equal to w[l] minus alpha, lambda over m times w[l], minus alpha times, you know, the thing you got from backprop. And so this term shows that whatever the matrix w[l] is, you're going to make it a little bit smaller, right? This is actually as if you're taking the matrix w and you're multiplying it by 1 minus alpha lambda over m. You're really taking the matrix w and subtracting alpha lambda over m times this. Like you're multiplying the matrix w by this number, which is going to be a little bit less than 1. So this is why L2 norm regularization is also called weight decay. Because it's just like the ordinary gradient descent, where you update w by subtracting alpha, times the original gradient you got from backprop. But now you're also, you know, multiplying w by this thing, which is a little bit less than 1. So the alternative name for L2 regularization is weight decay. I'm not really going to use that name, but the intuition for why it's called weight decay is that this first term here, is equal to this. So you're just multiplying the weight matrix by a number slightly less than 1. So that's how you implement L2 regularization in a neural network.\nNow, one question that peer centers ask me is, you know, \"Hey, Andrew, why does regularization prevent over-fitting?\" Let's take a quick look at the next video, and gain some intuition for how regularization prevents over-fitting.\n\nWhy Regularization Reduces Overfitting?\n\nWhy does regularization help with overfitting? Why does it help with reducing variance problems? Let's go through a couple examples to gain some intuition about how it works. So, recall that our high bias, high variance, and \"just write\" pictures from our earlier video had looked something like this. Now, let's see a fitting large and deep neural network. I know I haven't drawn this one too large or too deep, but let's see if [INAUDIBLE] some neural network and is currently overfitting. So you have some cost function, write J of W, b equals sum of the losses, like so, right? And so what we did for regularization was add this extra term that penalizes the weight matrices from being too large. And we said that was the Frobenius norm. So why is it that shrinking the L2 norm, or the Frobenius norm with the parameters might cause less overfitting? One piece of intuition is that if you, you know, crank your regularization lambda to be really, really big, that'll be really incentivized to set the weight matrices, W, to be reasonably close to zero. So one piece of intuition is maybe it'll set the weight to be so close to zero for a lot of hidden units that's basically zeroing out a lot of the impact of these hidden units. And if that's the case, then, you know, this much simplified neural network becomes a much smaller neural network. In fact, it is almost like a logistic regression unit, you know, but stacked multiple layers deep. And so that will take you from this overfitting case, much closer to the left, to the other high bias case. But, hopefully, there'll be an intermediate value of lambda that results in the result closer to this \"just right\" case in the middle. But the intuition is that by cranking up lambda to be really big, it'll set W close to zero, which, in practice, this isn't actually what happens. We can think of it as zeroing out, or at least reducing, the impact of a lot of the hidden units, so you end up with what might feel like a simpler network, that gets closer and closer as if you're just using logistic regression. The intuition of completely zeroing out a bunch of hidden units isn't quite right. It turns out that what actually happens is it'll still use all the hidden units, but each of them would just have a much smaller effect. But you do end up with a simpler network, and as if you have a smaller network that is, therefore, less prone to overfitting. So I'm not sure if this intuition helps, but when you implement regularization in the program exercise, you actually see some of these variance reduction results yourself. Here's another attempt at additional intuition for why regularization helps prevent overfitting. And for this, I'm going to assume that we're using the tan h activation function, which looks like this. This is g of z equals tan h of z. So if that's the case, notice that so long as z is quite small, so if z takes on only a smallish range of parameters, maybe around here, then you're just using the linear regime of the tan h function, is only if z is allowed to wander, you know, to larger values or smaller values like so, that the activation function starts to become less linear. So the intuition you might take away from this is that if lambda, the regularization parameter is large, then you have that your parameters will be relatively small, because they are penalized being large in the cost function. And so if the weights, W, are small, then because z is equal to W, right, and then technically, it's plus b. But if W tends to be very small, then z will also be relatively small. And in particular, if z ends up taking relatively small values, just in this little range, then g of z will be roughly linear. So it's as if every layer will be roughly linear, as if it is just linear regression. And we saw in course one that if every layer is linear, then your whole network is just a linear network. And so even a very deep network, with a deep network with a linear activation function is, at the end of the day, only able to compute a linear function. So it's not able to, you know, fit those very, very complicated decision, very non-linear decision boundaries that allow it to, you know, really overfit, right, to data sets, like we saw on the overfitting high variance case on the previous slide, ok? So just to summarize, if the regularization parameters are very large, the parameters W very small, so z will be relatively small, kind of ignoring the effects of b for now, but so z is relatively, so z will be relatively small, or really, I should say it takes on a small range of values. And so the activation function if it's tan h, say, will be relatively linear. And so your whole neural network will be computing something not too far from a big linear function, which is therefore, pretty simple function, rather than a very complex highly non-linear function. And so, is also much less able to overfit, ok? And again, when you implement regularization for yourself in the program exercise, you'll be able to see some of these effects yourself. Before wrapping up our def discussion on regularization, I just want to give you one implementational tip, which is that, when implementing regularization, we took our definition of the cost function J and we actually modified it by adding this extra term that penalizes the weights being too large. And so if you implement gradient descent, one of the steps to debug gradient descent is to plot the cost function J, as a function of the number of elevations of gradient descent, and you want to see that the cost function J decreases monotonically after every elevation of gradient descent. And if you're implementing regularization, then please remember that J now has this new definition. If you plot the old definition of J, just this first term, then you might not see a decrease monotonically. So to debug gradient descent, make sure that you're plotting, you know, this new definition of J that includes this second term as well. Otherwise, you might not see J decrease monotonically on every single elevation. So that's it for L2 regularization, which is actually a regularization technique that I use the most in training deep learning models. In deep learning, there is another sometimes used regularization technique called dropout regularization. Let's take a look at that in the next video.\n\nDropout Regularization\nIn addition to L2 regularization, another very powerful regularization techniques is called \"dropout.\" Let's see how that works. Let's say you train a neural network like the one on the left and there's over-fitting. Here's what you do with dropout. Let me make a copy of the neural network. With dropout, what we're going to do is go through each of the layers of the network and set some probability of eliminating a node in neural network. Let's say that for each of these layers, we're going to- for each node, toss a coin and have a 0.5 chance of keeping each node and 0.5 chance of removing each node. So, after the coin tosses, maybe we'll decide to eliminate those nodes, then what you do is actually remove all the outgoing things from that no as well. So you end up with a much smaller, really much diminished network. And then you do back propagation training. There's one example on this much diminished network. And then on different examples, you would toss a set of coins again and keep a different set of nodes and then dropout or eliminate different than nodes. And so for each training example, you would train it using one of these neural based networks. So, maybe it seems like a slightly crazy technique. They just go around coding those are random, but this actually works. But you can imagine that because you're training a much smaller network on each example or maybe just give a sense for why you end up able to regularize the network, because these much smaller networks are being trained. Let's look at how you implement dropout. There are a few ways of implementing dropout. I'm going to show you the most common one, which is technique called inverted dropout. For the sake of completeness, let's say we want to illustrate this with layer l=3. So, in the code I'm going to write- there will be a bunch of 3s here. I'm just illustrating how to represent dropout in a single layer. So, what we are going to do is set a vector d and d^3 is going to be the dropout vector for the layer 3. That's what the 3 is to be np.random.rand(a). And this is going to be the same shape as a3. And when I see if this is less than some number, which I'm going to call keep.prob. And so, keep.prob is a number. It was 0.5 on the previous time, and maybe now I'll use 0.8 in this example, and there will be the probability that a given hidden unit will be kept. So keep.prob = 0.8, then this means that there's a 0.2 chance of eliminating any hidden unit. So, what it does is it generates a random matrix. And this works as well if you have factorized. So d3 will be a matrix. Therefore, each example have a each hidden unit there's a 0.8 chance that the corresponding d3 will be one, and a 20% chance there will be zero. So, this random numbers being less than 0.8 it has a 0.8 chance of being one or be true, and 20% or 0.2 chance of being false, of being zero. And then what you are going to do is take your activations from the third layer, let me just call it a3 in this low example. So, a3 has the activations you computate. And you can set a3 to be equal to the old a3, times- There is element wise multiplication. Or you can also write this as a3* = d3. But what this does is for every element of d3 that's equal to zero. And there was a 20% chance of each of the elements being zero, just multiply operation ends up zeroing out, the corresponding element of d3. If you do this in python, technically d3 will be a boolean array where value is true and false, rather than one and zero. But the multiply operation works and will interpret the true and false values as one and zero. If you try this yourself in python, you'll see. Then finally, we're going to take a3 and scale it up by dividing by 0.8 or really dividing by our keep.prob parameter. So, let me explain what this final step is doing. Let's say for the sake of argument that you have 50 units or 50 neurons in the third hidden layer. So maybe a3 is 50 by one dimensional or if you- factorization maybe it's 50 by m dimensional. So, if you have a 80% chance of keeping them and 20% chance of eliminating them. This means that on average, you end up with 10 units shut off or 10 units zeroed out. And so now, if you look at the value of z^4, z^4 is going to be equal to w^4 * a^3 + b^4. And so, on expectation, this will be reduced by 20%. By which I mean that 20% of the elements of a3 will be zeroed out. So, in order to not reduce the expected value of z^4, what you do is you need to take this, and divide it by 0.8 because this will correct or just a bump that back up by roughly 20% that you need. So it's not changed the expected value of a3. And, so this line here is what's called the inverted dropout technique. And its effect is that, no matter what you set to keep.prob to, whether it's 0.8 or 0.9 or even one, if it's set to one then there's no dropout, because it's keeping everything or 0.5 or whatever, this inverted dropout technique by dividing by the keep.prob, it ensures that the expected value of a3 remains the same. And it turns out that at test time, when you trying to evaluate a neural network, which we'll talk about on the next slide, this inverted dropout technique, There's this slide, just green box around the next test This makes test time easier because you have less of a scaling problem. By far the most common implementation of dropouts today as far as I know is inverted dropouts. I recommend you just implement this. But there were some early iterations of dropout that missed this divide by keep.prob line, and so at test time the average becomes more and more complicated. But again, people tend not to use those other versions. So, what you do is you use the d vector, and you'll notice that for different training examples, you zero out different hidden units. And in fact, if you make multiple passes through the same training set, then on different pauses through the training set, you should randomly zero out different hidden units. So, it's not that for one example, you should keep zeroing out the same hidden units is that, on iteration one of grade and descent, you might zero out some hidden units. And on the second iteration of great descent where you go through the training set the second time, maybe you'll zero out a different pattern of hidden units. And the vector d or d3, for the third layer, is used to decide what to zero out, both in for prob as well as in that prob. We are just showing for prob here. Now, having trained the algorithm at test time, here's what you would do. At test time, you're given some x or which you want to make a prediction. And using our standard notation, I'm going to use a^0, the activations of the zeroes layer to denote just test example x. So what we're going to do is not to use dropout at test time in particular which is in a sense. Z^1= w^1.a^0 + b^1. a^1 = g^1(z^1 Z). Z^2 = w^2.a^1 + b^2. a^2 =... And so on. Until you get to the last layer and that you make a prediction y^. But notice that the test time you're not using dropout explicitly and you're not tossing coins at random, you're not flipping coins to decide which hidden units to eliminate. And that's because when you are making predictions at the test time, you don't really want your output to be random. If you are implementing dropout at test time, that just add noise to your predictions. In theory, one thing you could do is run a prediction process many times with different hidden units randomly dropped out and have it across them. But that's computationally inefficient and will give you roughly the same result; very, very similar results to this different procedure as well. And just to mention, the inverted dropout thing, you remember the step on the previous line when we divided by the cheap.prob. The effect of that was to ensure that even when you don't see men dropout at test time to the scaling, the expected value of these activations don't change. So, you don't need to add in an extra funny scaling parameter at test time. That's different than when you have that training time. So that's dropouts. And when you implement this in week's premier exercise, you gain more firsthand experience with it as well. But why does it really work? What I want to do the next video is give you some better intuition about what dropout really is doing. Let's go on to the next video.\n\nUnderstanding Dropout\nDrop out. Does this seemingly crazy thing of randomly knocking out units in your network? Why does it work? So as a regulizer, let's give some better intuition. In the previous video, I gave this intuition that drop out randomly knocks out units in your network. So it's as if on every iteration you're working with a smaller neural network. And so using a smaller neural network seems like it should have a regularizing effect. Here's the second intuition which is, you know, let's look at it from the perspective of a single unit. Right, let's say this one. Now for this unit to do his job has four inputs and it needs to generate some meaningful output. Now with drop out, the inputs can get randomly eliminated. You know, sometimes those two units will get eliminated. Sometimes a different unit will get eliminated. So what this means is that this unit which I'm circling purple. It can't rely on anyone feature because anyone feature could go away at random or anyone of its own inputs could go away at random. So in particular, I will be reluctant to put all of its bets on say just this input, right. The ways were reluctant to put too much weight on anyone input because it could go away. So this unit will be more motivated to spread out this ways and give you a little bit of weight to each of the four inputs to this unit. And by spreading out the weights this will tend to have an effect of shrinking the squared norm of the weights, and so similar to what we saw with L2 regularization. The effect of implementing dropout is that its strength the ways and similar to L2 regularization, it helps to prevent overfitting, but it turns out that dropout can formally be shown to be an adaptive form of L2 regularization, but the L2 penalty on different ways are different depending on the size of the activation is being multiplied into that way. But to summarize it is possible to show that dropout has a similar effect to. L2 regularization. Only the L2 regularization applied to different ways can be a little bit different and even more adaptive to the scale of different inputs. One more detail for when you're implementing dropout, here's a network where you have three input features. This is seven hidden units here. 7, 3, 2, 1, so one of the practice we have to choose was the keep prop which is a chance of keeping a unit in each layer. So it is also feasible to vary keep-propped by layer. So for the first layer, your matrix W1 will be 7 by 3. Your second weight matrix will be 7 by 7. W3 will be 3 by 7 and so on. And so W2 is actually the biggest weight matrix, right? Because they're actually the largest set of parameters. B and W2, which is 7 by 7. So to prevent, to reduce overfitting of that matrix, maybe for this layer, I guess this is layer 2, you might have a key prop that's relatively low, say 0.5, whereas for different layers where you might worry less about over 15, you could have a higher key problem. Maybe just 0.7, maybe this is 0.7. And then for layers we don't worry about overfitting at all. You can have a key prop of 1.0. Right? So, you know, for clarity, these are numbers I'm drawing in the purple boxes. These could be different key props for different layers. Notice that the key problem 1.0 means that you're keeping every unit. And so you're really not using drop out for that layer. But for layers where you're more worried about overfitting really the layers with a lot of parameters you could say keep prop to be smaller to apply a more powerful form of dropout. It's kind of like cranking up the regularization. Parameter lambda of L2 regularization where you try to regularize some layers more than others. And technically you can also apply drop out to the input layer where you can have some chance of just acting out one or more of the input features, although in practice, usually don't do that often. And so key problem of 1.0 is quite common for the input there. You might also use a very high value, maybe 0.9 but is much less likely that you want to eliminate half of the input features so usually keep prop. If you apply that all will be a number close to 1. If you even apply dropout at all to the input layer. So just to summarize if you're more worried about some layers of fitting than others, you can set a lower key prop for some layers than others. The downside is this gives you even more hyper parameters to search for using cross validation. One other alternative might be to have some layers where you apply dropout and some layers where you don't apply drop out and then just have one hyper parameter which is a key prop for the layers for which you do apply drop out and before we wrap up just a couple implantation all tips. Many of the first successful implementations of dropouts were to computer vision, so in computer vision, the input sizes so big in putting all these pixels that you almost never have enough data. And so drop out is very frequently used by the computer vision and there are some common vision research is that pretty much always use it almost as a default. But really, the thing to remember is that drop out is a regularization technique, it helps prevent overfitting. And so unless my avram is overfitting, I wouldn't actually bother to use drop out. So as you somewhat less often in other application areas, there's just a computer vision, you usually just don't have enough data so you almost always overfitting, which is why they tend to be some computer vision researchers swear by drop out by the intuition. I was, doesn't always generalize, I think to other disciplines. One big downside of drop out is that the cost function J is no longer well defined on every iteration. You're randomly, calling off a bunch of notes. And so if you are double checking the performance of great inter sent is actually harder to double check that, right? You have a well defined cost function J. That is going downhill on every elevation because the cost function J. That you're optimizing is actually less. Less well defined or it's certainly hard to calculate. So you lose this debugging tool to have a plot a draft like this. So what I usually do is turn off drop out or if you will set keep-propped = 1 and run my code and make sure that it is monitored quickly decreasing J. And then turn on drop out and hope that, I didn't introduce, welcome to my code during drop out because you need other ways, I guess, but not plotting these figures to make sure that your code is working, the greatest is working even with drop out. So with that there's still a few more regularization techniques that were feel knowing. Let's talk about a few more such techniques in the next video.\n\nNormalizing Inputs\nWhen training a neural network, one of the techniques to speed up your training is if you normalize your inputs. Let's see what that means. Let's see the training sets with two input features. The input features x are two-dimensional and here's a scatter plot of your training set. Normalizing your inputs corresponds to two steps, the first is to subtract out or to zero out the mean, so your sets mu equals 1 over m, sum over I of x_i. This is a vector and then x gets set as x minus mu for every training example. This means that you just move the training set until it has zero mean. Then the second step is to normalize the variances. Notice here that the feature x_1 has a much larger variance than the feature x_2 here. What we do is set sigma equals 1 over m sum of x_i star, star 2. I guess this is element-y squaring. Now sigma squared is a vector with the variances of each of the features. Notice we've already subtracted out the mean, so x_i squared, element-y square is just the variances. You take each example and divide it by this vector sigma. In some pictures, you end up with this where now the variance of x_1 and x_2 are both equal to one. One tip. If you use this to scale your training data, then use the same mu and sigma to normalize your test set. In particular, you don't want to normalize the training set and a test set differently. Whatever this value is and whatever this value is, use them in these two formulas so that you scale your test set in exactly the same way rather than estimating mu and sigma squared separately on your training set and test set, because you want your data both training and test examples to go through the same transformation defined by the same Mu and Sigma squared calculated on your training data. Why do we do this? Why do we want to normalize the input features? Recall that the cost function is defined as written on the top right. It turns out that if you use unnormalized input features, it's more likely that your cost function will look like this, like a very squished out bar, very elongated cost function where the minimum you're trying to find is maybe over there. But if your features are on very different scales, say the feature x_1 ranges from 1-1,000 and the feature x_2 ranges from 0-1, then it turns out that the ratio or the range of values for the parameters w_1 and w_2 will end up taking on very different values. Maybe these axes should be w_1 and w_2, but the intuition of plot w and b, cost function can be very elongated bow like that. If you plot the contours of this function, you can have a very elongated function like that. Whereas if you normalize the features, then your cost function will on average look more symmetric. If you are running gradient descent on a cost function like the one on the left, then you might have to use a very small learning rate because if you're here, the gradient decent might need a lot of steps to oscillate back and forth before it finally finds its way to the minimum. Whereas if you have more spherical contours, then wherever you start, gradient descent can pretty much go straight to the minimum. You can take much larger steps where gradient descent need, rather than needing to oscillate around like the picture on the left. Of course, in practice, w is a high dimensional vector. Trying to plot this in 2D doesn't convey all the intuitions correctly. But the rough intuition that you cost function will be in a more round and easier to optimize when you're features are on similar scales. Not from 1-1000, 0-1, but mostly from minus 1-1 or about similar variance as each other. That just makes your cost function j easier and faster to optimize. In practice, if one feature, say x_1 ranges from 0-1 and x_2 ranges from minus 1-1, and x_3 ranges from 1-2, these are fairly similar ranges, so this will work just fine, is when they are on dramatically different ranges like ones from 1-1000 and another from 0-1. That really hurts your optimization algorithm. That by just setting all of them to zero mean and say variance one like we did on the last slide, that just guarantees that all your features are in a similar scale and will usually help you learning algorithm run faster. If your input features came from very different scales, maybe some features are from 0-1, sum from 1-1000, then it's important to normalize your features. If your features came in on similar scales, then this step is less important although performing this type of normalization pretty much never does any harm. Often you'll do it anyway, if I'm not sure whether or not it will help with speeding up training for your algorithm. That's it for normalizing your input features. Next, let's keep talking about ways to speed up the training of your neural network.\n\nVanishing / Exploding Gradients\nOne of the problems of training neural network, especially very deep neural networks, is data vanishing and exploding gradients. What that means is that when you're training a very deep network your derivatives or your slopes can sometimes get either very, very big or very, very small, maybe even exponentially small, and this makes training difficult. In this video you see what this problem of exploding and vanishing gradients really means, as well as how you can use careful choices of the random weight initialization to significantly reduce this problem. Unless you're training a very deep neural network like this, to save space on the slide, I've drawn it as if you have only two hidden units per layer, but it could be more as well. But this neural network will have parameters W1, W2, W3 and so on up to WL. For the sake of simplicity, let's say we're using an activation function G of Z equals Z, so linear activation function. And let's ignore B, let's say B of L equals zero. So in that case you can show that the output Y will be WL times WL minus one times WL minus two, dot, dot, dot down to the W3, W2, W1 times X. But if you want to just check my math, W1 times X is going to be Z1, because B is equal to zero. So Z1 is equal to, I guess, W1 times X and then plus B which is zero. But then A1 is equal to G of Z1. But because we use linear activation function, this is just equal to Z1. So this first term W1X is equal to A1. And then by the reasoning you can figure out that W2 times W1 times X is equal to A2, because that's going to be G of Z2, is going to be G of W2 times A1 which you can plug that in here. So this thing is going to be equal to A2, and then this thing is going to be A3 and so on until the protocol of all these matrices gives you Y-hat, not Y. Now, let's say that each of you weight matrices WL is just a little bit larger than one times the identity. So it's 1.5_1.5_0_0. Technically, the last one has different dimensions so maybe this is just the rest of these weight matrices. Then Y-hat will be, ignoring this last one with different dimension, this 1.5_0_0_1.5 matrix to the power of L minus 1 times X, because we assume that each one of these matrices is equal to this thing. It's really 1.5 times the identity matrix, then you end up with this calculation. And so Y-hat will be essentially 1.5 to the power of L, to the power of L minus 1 times X, and if L was large for very deep neural network, Y-hat will be very large. In fact, it just grows exponentially, it grows like 1.5 to the number of layers. And so if you have a very deep neural network, the value of Y will explode. Now, conversely, if we replace this with 0.5, so something less than 1, then this becomes 0.5 to the power of L. This matrix becomes 0.5 to the L minus one times X, again ignoring WL. And so each of your matrices are less than 1, then let's say X1, X2 were one one, then the activations will be one half, one half, one fourth, one fourth, one eighth, one eighth, and so on until this becomes one over two to the L. So the activation values will decrease exponentially as a function of the def, as a function of the number of layers L of the network. So in the very deep network, the activations end up decreasing exponentially. So the intuition I hope you can take away from this is that at the weights W, if they're all just a little bit bigger than one or just a little bit bigger than the identity matrix, then with a very deep network the activations can explode. And if W is just a little bit less than identity. So this maybe here's 0.9, 0.9, then you have a very deep network, the activations will decrease exponentially. And even though I went through this argument in terms of activations increasing or decreasing exponentially as a function of L, a similar argument can be used to show that the derivatives or the gradients the computer is going to send will also increase exponentially or decrease exponentially as a function of the number of layers. With some of the modern neural networks, L equals 150. Microsoft recently got great results with 152 layer neural network. But with such a deep neural network, if your activations or gradients increase or decrease exponentially as a function of L, then these values could get really big or really small. And this makes training difficult, especially if your gradients are exponentially smaller than L, then gradient descent will take tiny little steps. It will take a long time for gradient descent to learn anything. To summarize, you've seen how deep networks suffer from the problems of vanishing or exploding gradients. In fact, for a long time this problem was a huge barrier to training deep neural networks. It turns out there's a partial solution that doesn't completely solve this problem but it helps a lot which is careful choice of how you initialize the weights. To see that, let's go to the next video.\n\nWeight Initialization for Deep Networks\nIn the last video you saw how very deep neural networks can have the problems of vanishing and exploding gradients. It turns out that a partial solution to this, doesn't solve it entirely but helps a lot, is better or more careful choice of the random initialization for your neural network. To understand this, let's start with the example of initializing the ways for a single neuron, and then we're go on to generalize this to a deep network. Let's go through this with an example with just a single neuron, and then we'll talk about the deep net later. So with a single neuron, you might input four features, x1 through x4, and then you have some a=g(z) and then it outputs some y. And later on for a deeper net, you know these inputs will be right, some layer a(l), but for now let's just call this x for now. So z is going to be equal to w1x1 + w2x2 +... + I guess WnXn. And let's set b=0 so, you know, let's just ignore b for now. So in order to make z not blow up and not become too small, you notice that the larger n is, the smaller you want Wi to be, right? Because z is the sum of the WiXi. And so if you're adding up a lot of these terms, you want each of these terms to be smaller. One reasonable thing to do would be to set the variance of W to be equal to 1 over n, where n is the number of input features that's going into a neuron. So in practice, what you can do is set the weight matrix W for a certain layer to be np.random.randn you know, and then whatever the shape of the matrix is for this out here, and then times square root of 1 over the number of features that I fed into each neuron in layer l. So there's going to be n(l-1) because that's the number of units that I'm feeding into each of the units in layer l. It turns out that if you're using a ReLu activation function that, rather than 1 over n it turns out that, set in the variance of 2 over n works a little bit better. So you often see that in initialization, especially if you're using a ReLu activation function. So if gl(z) is ReLu(z), oh and it depends on how familiar you are with random variables. It turns out that something, a Gaussian random variable and then multiplying it by a square root of this, that sets the variance to be quoted this way, to be 2 over n. And the reason I went from n to this n superscript l-1 was, in this example with logistic regression which is at n input features, but the more general case layer l would have n(l-1) inputs each of the units in that layer. So if the input features of activations are roughly mean 0 and standard variance and variance 1 then this would cause z to also take on a similar scale. And this doesn't solve, but it definitely helps reduce the vanishing, exploding gradients problem, because it's trying to set each of the weight matrices w, you know, so that it's not too much bigger than 1 and not too much less than 1 so it doesn't explode or vanish too quickly. I've just mention some other variants. The version we just described is assuming a ReLu activation function and this by a paper by her et al. A few other variants, if you are using a TanH activation function then there's a paper that shows that instead of using the constant 2, it's better use the constant 1 and so 1 over this instead of 2. And so you multiply it by the square root of this. So this square root term will replace this term and you use this if you're using a TanH activation function. This is called Xavier initialization. And another version we're taught by Yoshua Bengio and his colleagues, you might see in some papers, but is to use this formula, which you know has some other theoretical justification, but I would say if you're using a ReLu activation function, which is really the most common activation function, I would use this formula. If you're using TanH you could try this version instead, and some authors will also use this. But in practice I think all of these formulas just give you a starting point. It gives you a default value to use for the variance of the initialization of your weight matrices. If you wish the variance here, this variance parameter could be another thing that you could tune with your hyperparameters. So you could have another parameter that multiplies into this formula and tune that multiplier as part of your hyperparameter surge. Sometimes tuning the hyperparameter has a modest size effect. It's not one of the first hyperparameters I would usually try to tune, but I've also seen some problems where tuning this helps a reasonable amount. But this is usually lower down for me in terms of how important it is relative to the other hyperparameters you can tune. So I hope that gives you some intuition about the problem of vanishing or exploding gradients as well as choosing a reasonable scaling for how you initialize the weights. Hopefully that makes your weights not explode too quickly and not decay to zero too quickly, so you can train a reasonably deep network without the weights or the gradients exploding or vanishing too much. When you train deep networks, this is another trick that will help you make your neural networks trained much more quickly.\n\nNumerical Approximation of Gradients\nWhen you implement back propagation you'll find that there's a test called creating checking that can really help you make sure that your implementation of back prop is correct. Because sometimes you write all these equations and you're just not 100% sure if you've got all the details right and internal back propagation. So in order to build up to gradient and checking, let's first talk about how to numerically approximate computations of gradients and in the next video, we'll talk about how you can implement gradient checking to make sure the implementation of backdrop is correct. So let's take the function f and replot it here and remember this is f of theta equals theta cubed, and let's again start off to some value of theta. Let's say theta equals 1. Now instead of just nudging theta to the right to get theta plus epsilon, we're going to nudge it to the right and nudge it to the left to get theta minus epsilon, as was theta plus epsilon. So this is 1, this is 1.01, this is 0.99 where, again, epsilon is the same as before, it is 0.01. It turns out that rather than taking this little triangle and computing the height over the width, you can get a much better estimate of the gradient if you take this point, f of theta minus epsilon and this point, and you instead compute the height over width of this bigger triangle. So for technical reasons which I won't go into, the height over width of this bigger green triangle gives you a much better approximation to the derivative at theta. And you saw it yourself, taking just this lower triangle in the upper right is as if you have two triangles, right? This one on the upper right and this one on the lower left. And you're kind of taking both of them into account by using this bigger green triangle. So rather than a one sided difference, you're taking a two sided difference. So let's work out the math. This point here is F of theta plus epsilon. This point here is F of theta minus epsilon. So the height of this big green triangle is f of theta plus epsilon minus f of theta minus epsilon. And then the width, this is 1 epsilon, this is 2 epsilon. So the width of this green triangle is 2 epsilon. So the height of the width is going to be first the height, so that's F of theta plus epsilon minus F of theta minus epsilon divided by the width. So that was 2 epsilon which we write that down here.\nAnd this should hopefully be close to g of theta. So plug in the values, remember f of theta is theta cubed. So this is theta plus epsilon is 1.01. So I take a cube of that minus 0.99 theta cube of that divided by 2 times 0.01. Feel free to pause the video and practice in the calculator. You should get that this is 3.0001. Whereas from the previous slide, we saw that g of theta, this was 3 theta squared so when theta was 1, so these two values are actually very close to each other. The approximation error is now 0.0001. Whereas on the previous slide, we've taken the one sided of difference just theta + theta + epsilon we had gotten 3.0301 and so the approximation error was 0.03 rather than 0.0001. So this two sided difference way of approximating the derivative you find that this is extremely close to 3. And so this gives you a much greater confidence that g of theta is probably a correct implementation of the derivative of F.\nWhen you use this method for grading, checking and back propagation, this turns out to run twice as slow as you were to use a one-sided defense. It turns out that in practice I think it's worth it to use this other method because it's just much more accurate. The little bit of optional theory for those of you that are a little bit more familiar of Calculus, it turns out that, and it's okay if you don't get what I'm about to say here. But it turns out that the formal definition of a derivative is for very small values of epsilon is f of theta plus epsilon minus f of theta minus epsilon over 2 epsilon. And the formal definition of derivative is in the limits of exactly that formula on the right as epsilon those as 0. And the definition of unlimited is something that you learned if you took a Calculus class but I won't go into that here. And it turns out that for a non zero value of epsilon, you can show that the error of this approximation is on the order of epsilon squared, and remember epsilon is a very small number. So if epsilon is 0.01 which it is here then epsilon squared is 0.0001. The big O notation means the error is actually some constant times this, but this is actually exactly our approximation error. So the big O constant happens to be 1. Whereas in contrast if we were to use this formula, the other one, then the error is on the order of epsilon. And again, when epsilon is a number less than 1, then epsilon is actually much bigger than epsilon squared which is why this formula here is actually much less accurate approximation than this formula on the left. Which is why when doing gradient checking, we rather use this two-sided difference when you compute f of theta plus epsilon minus f of theta minus epsilon and then divide by 2 epsilon rather than just one sided difference which is less accurate.\nIf you didn't understand my last two comments, all of these things are on here. Don't worry about it. That's really more for those of you that are a bit more familiar with Calculus, and with numerical approximations. But the takeaway is that this two-sided difference formula is much more accurate. And so that's what we're going to use when we do gradient checking in the next video.\nSo you've seen how by taking a two sided difference, you can numerically verify whether or not a function g, g of theta that someone else gives you is a correct implementation of the derivative of a function f. Let's now see how we can use this to verify whether or not your back propagation implementation is correct or if there might be a bug in there that you need to go and tease out\n\n\nGradient Checking\nGradient checking is a technique that's helped me save tons of time, and helped me find bugs in my implementations of back propagation many times. Let's see how you could use it too to debug, or to verify that your implementation and back process correct. So your new network will have some sort of parameters, W1, B1 and so on up to WL bL. So to implement gradient checking, the first thing you should do is take all your parameters and reshape them into a giant vector data. So what you should do is take W which is a matrix, and reshape it into a vector. You gotta take all of these Ws and reshape them into vectors, and then concatenate all of these things, so that you have a giant vector theta. Giant vector pronounced as theta. So we say that the cos function J being a function of the Ws and Bs, You would now have the cost function J being just a function of theta. Next, with W and B ordered the same way, you can also take dW[1], db[1] and so on, and initiate them into big, giant vector d theta of the same dimension as theta. So same as before, we shape dW[1] into the matrix, db[1] is already a vector. We shape dW[L], all of the dW's which are matrices. Remember, dW1 has the same dimension as W1. db1 has the same dimension as b1. So the same sort of reshaping and concatenation operation, you can then reshape all of these derivatives into a giant vector d theta. Which has the same dimension as theta. So the question is, now, is the theta the gradient or the slope of the cos function J? So here's how you implement gradient checking, and often abbreviate gradient checking to grad check. So first we remember that J Is now a function of the giant parameter, theta, right? So expands to j is a function of theta 1, theta 2, theta 3, and so on.\nWhatever's the dimension of this giant parameter vector theta. So to implement grad check, what you're going to do is implements a loop so that for each I, so for each component of theta, let's compute D theta approx i to b. And let me take a two sided difference. So I'll take J of theta. Theta 1, theta 2, up to theta i. And we're going to nudge theta i to add epsilon to this. So just increase theta i by epsilon, and keep everything else the same. And because we're taking a two sided difference, we're going to do the same on the other side with theta i, but now minus epsilon. And then all of the other elements of theta are left alone. And then we'll take this, and we'll divide it by 2 theta. And what we saw from the previous video is that this should be approximately equal to d theta i. Of which is supposed to be the partial derivative of J or of respect to, I guess theta i, if d theta i is the derivative of the cost function J. So what you going to do is you're going to compute to this for every value of i. And at the end, you now end up with two vectors. You end up with this d theta approx, and this is going to be the same dimension as d theta. And both of these are in turn the same dimension as theta. And what you want to do is check if these vectors are approximately equal to each other. So, in detail, well how you do you define whether or not two vectors are really reasonably close to each other? What I do is the following. I would compute the distance between these two vectors, d theta approx minus d theta, so just the o2 norm of this. Notice there's no square on top, so this is the sum of squares of elements of the differences, and then you take a square root, as you get the Euclidean distance. And then just to normalize by the lengths of these vectors, divide by d theta approx plus d theta. Just take the Euclidean lengths of these vectors. And the row for the denominator is just in case any of these vectors are really small or really large, your the denominator turns this formula into a ratio. So we implement this in practice, I use epsilon equals maybe 10 to the minus 7, so minus 7. And with this range of epsilon, if you find that this formula gives you a value like 10 to the minus 7 or smaller, then that's great. It means that your derivative approximation is very likely correct. This is just a very small value. If it's maybe on the range of 10 to the -5, I would take a careful look. Maybe this is okay. But I might double-check the components of this vector, and make sure that none of the components are too large. And if some of the components of this difference are very large, then maybe you have a bug somewhere. And if this formula on the left is on the other is -3, then I would wherever you have would be much more concerned that maybe there's a bug somewhere. But you should really be getting values much smaller then 10 minus 3. If any bigger than 10 to minus 3, then I would be quite concerned. I would be seriously worried that there might be a bug. And I would then, you should then look at the individual components of data to see if there's a specific value of i for which d theta across i is very different from d theta i. And use that to try to track down whether or not some of your derivative computations might be incorrect. And after some amounts of debugging, it finally, it ends up being this kind of very small value, then you probably have a correct implementation. So when implementing a neural network, what often happens is I'll implement foreprop, implement backprop. And then I might find that this grad check has a relatively big value. And then I will suspect that there must be a bug, go in debug, debug, debug. And after debugging for a while, If I find that it passes grad check with a small value, then you can be much more confident that it's then correct. So you now know how gradient checking works. This has helped me find lots of bugs in my implementations of neural nets, and I hope it'll help you too. In the next video, I want to share with you some tips or some notes on how to actually implement gradient checking. Let's go onto the next video.\n", "source": "coursera_c", "evaluation": "exam"}
